-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
88 lines (69 loc) · 2.02 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import utils
from flask import Flask
from flask import request
from flask import render_template
from flask import jsonify
from flask_bootstrap import Bootstrap
import os
import string
os.system(
'python3 spider.py')
app = Flask(__name__)
bootstrap = Bootstrap(app)
@app.route('/')
def hello_world():
return render_template("demo.html")
@app.route("/c1")
def get_c1_data():
data = utils.get_c1_data()
return jsonify({"confirm":data[0],"suspect":data[1],"heal":data[2],"dead":data[3]})
@app.route("/c2")
def get_c2_data():
res = []
for tup in utils.get_c2_data():
# print(tup)
res.append({"name":tup[0],"value":int(tup[1])})
return jsonify({"data":res})
@app.route("/l1")
def get_l1_data():
data = utils.get_l1_data()
day,confirm,suspect,heal,dead = [],[],[],[],[]
for a,b,c,d,e in data[7:]:
day.append(a.strftime("%m-%d"))
# a是datatime类型
confirm.append(b)
suspect.append(c)
heal.append(d)
dead.append(e)
return jsonify({"day": day, "confirm": confirm, "suspect": suspect, "heal": heal, "dead": dead})
@app.route("/l2")
def get_l2_data():
data = utils.get_l2_data()
day, confirm_add, suspect_add = [], [], []
for a, b, c in data[7:]:
day.append(a.strftime("%m-%d")) # a是datatime类型
confirm_add.append(b)
suspect_add.append(c)
return jsonify({"day": day, "confirm_add": confirm_add, "suspect_add": suspect_add})
@app.route("/r1")
def get_r1_data():
data = utils.get_r1_data()
city = []
confirm = []
for k,v in data:
city.append(k)
confirm.append(int(v))
return jsonify({"city": city, "confirm": confirm})
@app.route("/r2")
def get_r2_data():
res = []
for tup in utils.get_r2_data():
# print(tup)
res.append({"name": tup[0], "value": int(tup[1])})
return jsonify({"data": res})
@app.route("/time")
def get_time():
return utils.get_time()
if __name__ == '__main__':
# app.run(host='127.0.0.1', port=5000)
bootstrap.run()