-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
45 lines (33 loc) · 1.12 KB
/
Copy pathapp.py
File metadata and controls
45 lines (33 loc) · 1.12 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
# This is the engine of the REST based flask API
from flask import Flask, render_template, request, redirect, url_for, jsonify
import pickle
from model import Recommendation
recommend = Recommendation()
app = Flask(__name__) # intitialize the flaks app # common
import os
from flask import send_from_directory
@app.route('/favicon.ico')
def favicon():
return send_from_directory(os.path.join(app.root_path, 'static'),
'favicon.ico', mimetype='image/vnd.microsoft.icon')
@app.route('/', methods = ['POST', 'GET'])
def home():
flag = False
data = ""
if request.method == 'POST':
flag = True
user = request.form["userid"]
data=recommend.getTopProducts(user)
return render_template('index.html', data=data, flag=flag)
@app.route('/userList', methods = ['GET'])
def userList():
data=recommend.getUsers()
return data
@app.route('/productList', methods = ['GET'])
def productList():
user=request.args.get("userid")
data=recommend.getTopProductsNew(user)
return data
if __name__ == '__main__' :
app.run(debug=True )
#,host="0.0.0.0")