-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnutrition.py
53 lines (46 loc) · 1.69 KB
/
nutrition.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
import flask, flask.views
import os
import utils
from itertools import izip
class Nutrition(flask.views.MethodView):
@utils.login_required
def get(self, page="nutrition"):
# Nutrition data, will later load from file
x = {
'Nutrient': [u'Calories (kcals)', u'Fat (g)', u'Saturated Fat (g)', u'Protein (g)', u'Carbohydrate (g)', u'Fiber (g)', u'Sodium (mg)'],
'Intake': [1530, 10, 1, 0, 10, 10, 300],
'Need': [1800, 10, 10, 10, 10, 10, 1000]}
x['Difference'] = [x1 - x2 for (x1, x2) in zip(x['Need'], x['Intake'])]
x2 = [dict(Nutrient=n, Intake=i, Need=r, Difference=d) for n,i,r,d in izip(x['Nutrient'], x['Intake'], x['Need'], x['Difference'])]
page += ".html"
if os.path.isfile('templates/' + page):
return flask.render_template(page, x=x2)
flask.abort(404)
# class coachNutrition(flask.views.MethodView):
# @utils.login_required
# def get(self, page="coach-nutrition"):
# page += ".html"
# if os.path.isfile('templates/' + page):
# return flask.render_template(page)
# flask.abort(404)
# class clientNutrition(flask.views.MethodView):
# @utils.login_required
# def get(self, page="client-nutrition"):
# page += ".html"
# if os.path.isfile('templates/' + page):
# return flask.render_template(page)
# flask.abort(404)
# class gformNutrition(flask.views.MethodView):
# @utils.login_required
# def get(self, page="gformNutrition"):
# page += ".html"
# if os.path.isfile('templates/' + page):
# return flask.render_template(page)
# flask.abort(404)
# class gres(flask.views.MethodView):
# @utils.login_required
# def get(self, page="gres"):
# page += ".html"
# if os.path.isfile('templates/' + page):
# return flask.render_template(page)
# flask.abort(404)