-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
32 lines (21 loc) · 677 Bytes
/
app.py
File metadata and controls
32 lines (21 loc) · 677 Bytes
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
from db_utils import get_recipes, get_recipe, insert_recipe
app = Flask(__name__)
@app.route('/')
def index():
return """This is a recipe API, you can retrieve, and submit recipes. See README for endpoints."""
@app.route('/get-recipes')
def call_get_recipes():
result = get_recipes()
return result
@app.route('/get-recipe/<name>')
def call_get_recipe(name):
result = get_recipe(name)
return result
@app.route('/submit-recipe', methods=["PUT"])
def call_insert_recipe():
recipe = request.get_json()
code = insert_recipe(recipe)
return code
if __name__ == '__main__':
app.run(debug=True, port=5001)