-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
67 lines (54 loc) · 2.03 KB
/
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
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 requests
import json
from flask import Flask, render_template, url_for, request
# from flask_mobility import Mobility
from flask_apscheduler import APScheduler
from dotenv import load_dotenv
load_dotenv()
import os
from getData import updateData
app = Flask(__name__)
# Mobility(app)
scheduler = APScheduler()
branch = os.getenv('branch')
@app.route('/')
def home():
table_url = f'https://raw.githubusercontent.com/carloscerlira/CoronaTrack/{branch}/data/general.json'
table = requests.get(table_url).json()
return render_template('home.html', table=table)
@app.route('/aboutData')
def aboutData():
return render_template('aboutData.html')
@app.route('/aboutCOVID')
def aboutCOVID():
return render_template('aboutCOVID.html')
@app.route('/aboutVaccines')
def aboutVaccines():
return render_template('aboutVaccines.html')
@app.route('/country/<string:country>')
def country(country):
# print(request.MOBILE)
data_url = f'https://raw.githubusercontent.com/carloscerlira/CoronaTrack/{branch}/data/time_series/{country}.json'
data = requests.get(data_url).json()
return render_template('countryInfo.html', data=data)
@app.route('/Mexico')
def Mexico():
table_url = f'https://raw.githubusercontent.com/carloscerlira/CoronaTrack/{branch}/data/mexico/general.json'
table = requests.get(table_url).json()
return render_template('homeState.html', table=table)
@app.route('/country/MX/<string:state>')
def state(state):
# print(request.MOBILE)
data_url = f'https://raw.githubusercontent.com/carloscerlira/CoronaTrack/{branch}/data/mexico/time_series/{state}.json'
data = requests.get(data_url).json()
return render_template('stateInfo.html', data=data)
@app.route('/test')
def test():
return render_template('test.html')
def scheduledTask():
access_token = os.getenv('access_token')
updateData(access_token)
scheduler.add_job(id='Scheduled task', func=scheduledTask, trigger='cron', timezone='UTC', hour=0, minute=20)
scheduler.start()
if __name__ == '__main__':
app.run(debug=True)