-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
104 lines (77 loc) · 2.23 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# -*- coding: utf-8 -*-
"""
--------------------------------------
Project Name: BigScreenDisplay
File Name: app.py
Author: Onway
Create Date: 2022/5/27
--------------------------------------
"""
import json
from flask import Flask, render_template, Response, jsonify
from flask_apscheduler import APScheduler
from data import getData
from dataCrawler import crawlData
import warnings
warnings.filterwarnings("ignore")
crawl = crawlData()
class Config(object):
JOBS = [{
'id': 'job1',
'func': 'app:run',
'args': (),
'trigger': 'cron',
'day': '*',
'hour': '10',
'minute': '28'
}
]
SCHEDULER_API_ENABLED = True
SCHEDULER_API_PREFIX = '/scheduler'
def run():
crawl.run()
app = Flask(__name__)
app.config.from_object(Config())
# 获取数据
getDataSource = getData()
@app.route("/province")
def jsonmongodb():
output = getDataSource.jsonmongodb()
return Response(json.dumps(output, ensure_ascii=False), mimetype='application/json')
@app.route('/echart1')
def echart1():
data = getDataSource.echart1()
return Response(json.dumps(data, ensure_ascii=False), mimetype='application/json')
@app.route('/echart2')
def echart2():
data = getDataSource.echart2()
return Response(json.dumps(data, ensure_ascii=False), mimetype='application/json')
@app.route('/echart3')
def echart3():
data = getDataSource.echart3()
return Response(json.dumps(data, ensure_ascii=False), mimetype='application/json')
@app.route('/echart4')
def echart4():
data = getDataSource.echart4()
return Response(json.dumps(data, ensure_ascii=False), mimetype='application/json')
@app.route('/echart5')
def echart5():
data = getDataSource.echart5()
return Response(json.dumps(data, ensure_ascii=False), mimetype='application/json')
@app.route('/echart6')
def echart6():
data = getDataSource.echart6()
return Response(json.dumps(data, ensure_ascii=False), mimetype='application/json')
@app.route('/')
def index():
title='中国&国际疫情实时追踪'
return render_template('index.html',title=title)
@app.route('/Title')
def Title():
data=getDataSource.Title()
return Response(json.dumps(data, ensure_ascii=False), mimetype='application/json')
scheduler = APScheduler()
scheduler.init_app(app)
scheduler.start()
if __name__ == "__main__":
app.run(debug=True)