-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
68 lines (51 loc) · 1.83 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
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
from urllib import request
from flask import Flask, jsonify, render_template
from filter import get_model
import pandas as pd
from getter import get_list
app = Flask(__name__, template_folder="templates",
static_folder="static", static_url_path="")
MODEL = get_model()
MOVIES = pd.read_csv('dataset//movies.csv')
# Valid user_ids: 13 and 276
@app.route('/<user_id>/<mood>/<company>')
def send_all(user_id, mood, company):
movie_list = list()
mood = int(mood)
company = int(company)
user_id = int(user_id)
if mood == 0 and company == 0:
movie_list = get_list(user_id*100+0, MODEL, MOVIES)
elif mood == 0 and company == 1:
movie_list = get_list(user_id*100+1, MODEL, MOVIES)
if mood == 0 and company == 2:
movie_list = get_list(user_id*100+2, MODEL, MOVIES)
if mood == 1 and company == 0:
movie_list = get_list(user_id*100+3, MODEL, MOVIES)
if mood == 1 and company == 1:
movie_list = get_list(user_id*100+4, MODEL, MOVIES)
if mood == 1 and company == 2:
movie_list = get_list(user_id*100+5, MODEL, MOVIES)
""" endpoint: takes HTTP request and return movie recommendation(s) """
lst = [MOVIES.query(f'Id=={i}')['Title']._values[0] for i in movie_list]
print(type(lst))
for i in lst:
print(i)
# return jsonify(lst)
return render_template("recommendation.html", movies=lst)
@app.route("/")
def pls_work():
return render_template("index.html")
@app.route("/login")
def login():
return render_template("login.html")
@app.route('/sliders')
def sliders():
# user = request.form.get('form-username')
# print(user)
return render_template("sliders.html")
@app.route('/recommendation')
def recommendations():
return render_template("recommendation.html", movies="")
if __name__ == '__main__':
app.run(debug=True)