forked from sydleither/meal-planner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
66 lines (46 loc) · 2.02 KB
/
main.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from flask import Flask, render_template, request
from controller.recipe_input_parser import parse_data
from controller.view_to_model import submit_recipe, submit_planner
from controller.model_to_view import all_recipes, single_recipe, planner
app = Flask(__name__, template_folder='view', static_folder='view')
@app.route('/', methods=['GET'])
def index():
return render_template('index.html')
@app.route('/planner/new', methods=['GET'])
def new_planner():
recipes = all_recipes()
return render_template('new_planner.html', recipes=recipes)
@app.route('/planner', methods=['POST'])
def new_planner_submit():
data = request.form
submit_planner(data)
planner_data = planner()
return render_template('planner.html', planner=planner_data)
@app.route('/planner', methods=['GET'])
def view_planner():
planner_data = planner()
return render_template('planner.html', planner=planner_data)
@app.route('/confirm', methods=['POST'])
def add_recipe():
data = request.form
global name, link, meal_type, subtype, servings, vegan
name, link, ingredients, instructions, meal_type, subtype, servings, vegan = parse_data(data)
return render_template('confirm.html', name=name, ingredients=ingredients, \
instructions=instructions, link=link, meal_type=meal_type, \
subtype=subtype, servings=servings, vegan=vegan)
@app.route('/', methods=['POST'])
def confirm_recipe():
data = request.form
submit_recipe(data, name, link, meal_type, subtype, servings, vegan)
return render_template('index.html')
@app.route('/recipes', methods=['GET'])
def view_recipes():
recipes = all_recipes()
return render_template('recipes.html', recipes=recipes)
@app.route('/recipe', methods=['GET'])
def view_recipe():
recipe_id = request.args.get('id')
recipe, ingredients = single_recipe(recipe_id)
return render_template('recipe.html', recipe_id=recipe_id, recipe=recipe, ingredients=ingredients)
if __name__ == '__main__':
app.run(debug=True)