-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
24 lines (18 loc) · 806 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
from flask import Flask, render_template, request
from model import SentimentBasedProductRecommendationSystem
recommondation_model = SentimentBasedProductRecommendationSystem()
app = Flask(__name__)
file_name = "index.html"
@app.route('/', methods = ['GET'])
def home():
return render_template(file_name, recommended_products="", show_results=False, show_no_user=False)
@app.route('/list-recommendations', methods = ['POST'])
def fetchRecommendations():
recommended_products=""
try:
recommended_products=recommondation_model.recommendProducts(request.form["user"])
except:
recommended_products=""
return render_template(file_name, recommended_products=recommended_products, show_results=True, show_no_user=True)
if __name__ == '__main__' :
app.run(debug=True)