forked from ishantk/GW2022PD1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSession18.py
67 lines (46 loc) · 1.61 KB
/
Session18.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
67
# Import all the Built in Classes/Functions from the flask module :)
from flask import *
from Session18A import DBHelper
from Session18B import HealthLogger
app = Flask("HealthLogger")
db_helper = DBHelper()
@app.route("/")
def index():
return render_template("index.html")
@app.route("/add")
def add_health_log():
return render_template("add-health-log.html")
@app.route("/logs")
def view_all_health_logs():
health_logger_object = HealthLogger()
sql = health_logger_object.fetch_sql_command()
rows = db_helper.read(sql)
return render_template("logs.html", result=rows)
@app.route("/save", methods=["POST"])
def save_health_data():
print("Save health Data Executed...")
"""
health_data = {
"phone": request.form['txtPhone'],
"weight": request.form['weight'],
"bphigh": request.form['bphigh'],
"bplow": request.form['bplow'],
"sugar": request.form['sugar'],
}
print("health_data dictionary:", health_data)
"""
health_data_object = HealthLogger(phone=request.form['txtPhone'],
weight=int(request.form['weight']),
bp_high=int(request.form['bphigh']),
bp_low=int(request.form['bplow']),
sugar=int(request.form['sugar']),
)
print(health_data_object)
sql = health_data_object.insert_sql_command()
print("SQL IS:", sql)
db_helper.write(sql)
return "Health Record Added :)"
def main():
app.run()
if __name__ == "__main__":
main()