-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
32 lines (23 loc) · 855 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
from flask import Flask, request, abort
from database.db import GraphDB
from models.user import User
from models.meal import Meal
app = Flask(__name__)
GraphDB.init_app(app)
@app.route('/meal-recommendation/user/<int:user_id>/get-meal', methods=['POST'])
def get_meal(user_id):
req_data = request.json
if not req_data:
abort(400)
return Meal.get_recommended_meals(user_id, req_data.get('cuisines'),
req_data.get('medical_conditions'), req_data.get('allergies'))
@app.route('/meal-recommendation/user', methods=['POST'])
def add_user():
req_data = request.json
if not req_data:
abort(400)
assert 'name' in req_data
assert 'age' in req_data
return User.register_user(req_data.get('name'), req_data.get('age'))
if __name__ == '__main__':
app.run(debug=True)