-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
35 lines (24 loc) · 1.22 KB
/
main.py
File metadata and controls
35 lines (24 loc) · 1.22 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
from flask import jsonify, Flask, request
from recommendation_api import calculate_similarity_vectors, generateUserPreferenceVector, return_max_similarity, get_recommend_by_userVector
from userpreference_update import returnVectorJson, UpdateUserPreferrence, trackTopNaccuracy
import json
app = Flask(__name__)
@app.route("/recommend",methods=["POST","GET"]) # 재료 다 고르자마자 실행
def send_recommended_json():
InputPythonJson = request.get_json()
return_recipe_id = get_recommend_by_userVector(InputPythonJson)
res = []
for recipe_ in return_recipe_id:
del recipe_['similarity']
for element_dict in return_recipe_id:
res.append(element_dict['id'])
return json.dumps(res),200
################ input example
@app.route("/userpreference_update",methods=["POST","GET"]) # 유저가 추천된 레시피 고르고 레이팅을 하던 안하던 레시피에서 나가고 나서 실행 고려중
def send_userpreference_json():
InputPythonJson = request.get_json()
trackTopNaccuracy(InputPythonJson)
outputJson = UpdateUserPreferrence(InputPythonJson)
return json.dumps({"output_json":outputJson}),200
app.run(host="0.0.0.0",port=5000,debug=True)
###### execute below statement