-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
41 lines (29 loc) · 1.03 KB
/
app.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
32
33
34
35
36
37
38
39
40
41
from sys import displayhook
from flask import Flask, render_template, request
import pickle
from numpy import mod
import pandas as pd
from getsongdetails import SongData
import creds
from helpers import *
model = loadModel("models/complexmodel.sav")
songDataLoader = SongData(creds.CLIENT_ID,creds.CLIENT_SECRET)
NUM_SONGS_SHOW = 10
app = Flask(
__name__,
template_folder="templates",
static_folder="static"
)
@app.route("/", methods = ["GET","POST"])
def predict():
if request.method == "POST":
song_id = request.form.get("song_id")
song_features = songDataLoader.getSongFeatures(song_id)
label = getLabel(model,
song_features)
indexListRet = getSongsWithLabel(label,NUM_SONGS_SHOW)
return render_template("index.html",label = str(label), displayForm = False, indexList = indexListRet)
else:
return render_template("index.html", label = "", displayForm = True, indexListRet = [])
if __name__ == "__main__":
app.run(debug=True)