-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
40 lines (30 loc) · 952 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
35
36
37
38
39
40
from flask import Flask, g, render_template
import sqlite3
import os
from flask import request
os.chdir(r"C:\Users\Áron\Desktop\covid\herd-immunity")
#connecting to db
def connect_db():
return sqlite3.connect('covid.db')
app = Flask(__name__)
phones = ["iphone", "android", "blackberry"]
#getting the data from the db
@app.route('/')
def get_data(name=None):
#get user data
agent = request.headers.get('User-Agent')
g.db = connect_db()
cur = g.db.execute('SELECT * FROM ImmunityDate WHERE FDDays < 4500 AND SDDays < 4500')
data = []
for row in cur.fetchall():
data.append(row)
g.db.close()
#send user to mobile site if on phone
if any(phone in agent.lower() for phone in phones):
return render_template("mobile-view.html", data = data)
return render_template('index.html', data=data)
#running
def main():
app.run(debug=False)
if __name__ == '__main__':
main()