-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
34 lines (24 loc) · 927 Bytes
/
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
from flask import Flask, render_template, url_for, request
from recommender_engine import get_recommendations
import os
import sys
app = Flask(__name__)
@app.route('/')
@app.route('/home', methods = ["GET", "POST"])
def home():
return render_template("home.html")
@app.route('/about')
def about():
return render_template("about.html")
@app.route('/result', methods = ["GET", "POST"])
def result():
if request.method == "POST":
movie_name = request.form["movie_name"]
sys.stdout.write("Movie name: {}".format(movie_name))
else:
movie_name = request.args.get("movie_name")
recommended_movies = get_recommendations(movie_name, 5)
# sys.stdout.write("Suggested five movies like {}, {}".format(recommended_movies[0], recommended_movies))
return render_template("result.html", given_movie = movie_name, movies = recommended_movies)
if __name__ == "__main__":
app.run(debug = True, host='0.0.0.0', port = 5001)