-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
39 lines (32 loc) · 1 KB
/
app.py
File metadata and controls
39 lines (32 loc) · 1 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
import numpy as np
from flask import Flask, request, jsonify, render_template
import pickle
from main import get_recommendations
import json
app = Flask(__name__)
model = pickle.load(open('movie.pkl', 'rb'))
@app.route('/')
def home():
return render_template('home.html')
@app.route('/predict',methods=['POST','GET'])
def predict():
'''
'''
# data = request.get_json
print(request.args)
data=request.args.get('movie')
film=get_recommendations(data)
print(film)
result = film.to_json(orient="split")
result2=json.loads(result)
#return render_template('home.html', prediction_text='Movies are jkl')
print(type(result))
return render_template('home.html', prediction_text='Movies are {}'.format(result2['data']))
@app.route('/predict_api',methods=['POST','GET'])
def predict_api():
data = request.get_json(force=True)
film=get_recommendations(data['exp'])
result = film.to_json(orient="split")
return result
if __name__ == "__main__":
app.run(debug=True)