-
Notifications
You must be signed in to change notification settings - Fork 0
/
app1.py
31 lines (24 loc) · 1.01 KB
/
app1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
''' Project 1: Milestone 1'''
from flask import Flask, render_template
from spotify import get_top_tracks
from genius import get_Song_Url
import os #module providing functions to create/delete directories and fetching its contents
import random
app1 = Flask(__name__) #initializes the app name
@app1.route('/')
def hello_world():
top_tracks = get_top_tracks() #calls the spotify api, gaining access to the return data
url_link = get_Song_Url(top_tracks['s_name'],top_tracks['s_track'])#calls the genius api, with artist name and song name from spotify included in parameters.
return render_template(# takes return data from spotify/genius api, sends it to html template
"song.html",
name=top_tracks['s_name'],
track=top_tracks['s_track'],
preview=top_tracks['s_preview'],
image=top_tracks['s_image'],
url=url_link['s_url']
)
if __name__ == "__main__":
app1.run(
port=int(os.getenv('PORT', 8080)),
host=os.getenv('IP', '0.0.0.0'),
)