-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
78 lines (67 loc) · 2.55 KB
/
app.py
File metadata and controls
78 lines (67 loc) · 2.55 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from flask import Flask, render_template, request, url_for, redirect, jsonify
from api_call import *
from flask_cors import CORS
import pygal
app = Flask(__name__)
app.static_folder = 'static'
CORS(app)
@app.route('/')
def home():
return(render_template('home.html', title='Song search'))
@app.route('/search')
def search():
name = request.args.get('search')
songs = song_search(name)
return(render_template('search.html', title='Search results', search=songs, name=name))
@app.route('/recs/<value>')
def recs(value):
songs = song_recs(value)
graph = songs[0]['graph_uri']
feats = songs[1]
li = [i['id'] for i in songs[2]]
name = 'the song you selected.'
title = "Recommendations"
return(render_template('recs.html',search=songs[2],graph=graph,feats=feats,li=li,name = name, title = title))
@app.route('/recs_mood')
def recs_mood():
acousticness = request.args.get('acousticness')
danceability = request.args.get('danceability')
duration_ms = request.args.get('duration_ms')
energy = request.args.get('energy')
instrumentalness = request.args.get('instrumentalness')
key = request.args.get('key')
liveness = request.args.get('liveness')
loudness = request.args.get('loudness')
mode = request.args.get('mode')
speechiness = request.args.get('speechiness')
tempo = request.args.get('tempo')
time_signature = request.args.get('time_signature')
valence = request.args.get('valence')
playlist = request.args.get('playlist')
name = 'the mood values you selected.'
songs = song_recs_mood(acousticness,
danceability,
duration_ms,
energy,
instrumentalness,
key,
liveness,
loudness,
mode,
speechiness,
tempo,
time_signature,
valence,
playlist)
graph = songs[0]['graph_uri']
feats = songs[1]
li = [i['id'] for i in songs[2]]
title='Mood Features'
return(render_template('recs.html', title=title,
search=songs[2],
graph=graph,
feats=feats,
li=li,
name = name))
if __name__ == '__main__':
app.run()