-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
executable file
·34 lines (24 loc) · 945 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
33
34
from flask import Flask,render_template,jsonify,request
import sqlite3
from utils import *
import json
app = Flask(__name__)
@app.route("/", methods=["GET"])
def main():
return render_template("index.html")
@app.route("/get_data", methods=["GET","POST"])
def api():
cur = db_connect()
alpha = device_connection(cur)
beta = heart_connection(cur)
gamma = fall_connection(cur)
delta = graph_connection(cur)
payload = json.dumps({**alpha,**beta,**gamma,**delta})
return payload
@app.route('/db_update',methods=['POST'])
def db_update():
data = request.form.to_dict(flat=False)
save_to_db(data['timestamp'][0],data['device_id'][0],data['is_fall'][0],data['heart_rate'][0])
if int(data['is_sms'][0]):
check_for_alert(data['sms_sender'][0],data['sms_reciever'][0],data['timestamp'][0],data['is_fall'][0],data['heart_rate'][0])
return 'saved to database'