from flask import Flask, render_template
from mydb import MyDB
from flask import jsonify
app = Flask(__name__)
@app.route('/hello')
def say_hello():
return '
Hello World
'
@app.route('/')
def hello():
return render_template('hello.html', name='Jerry')
@app.route('/province_topn_curconfirm')
def get_province_curconfirm_topn():
mydb = MyDB('localhost', 'root', 'Aa183365', 'covid19_datas')
results = mydb.get_province_curconfirm_top5() # results : []
return jsonify(pub_date=results[0][2], privinces=[x[0] for x in results], curConfirms=[x[1] for x in results])
@app.route('/country_topn_curconfirm')
def get_country_curconfirm_topn():
mydb1 = MyDB('localhost', 'root', 'Aa183365', 'covid19_datas')
results = mydb1.get_country_curconfirm_top10() # results : []
return jsonify(pub_date=results[0][2], privinces=[x[0] for x in results], curConfirms=[x[1] for x in results])
@app.route('/province_curconfirm')
def get_province_curconfirm():
mydb = MyDB('localhost', 'root', 'Aa183365', 'covid19_datas')
results = mydb.get_province_curConfirms() # results : [(), (), ...]
return jsonify(pub_date=results[0][2], provinces=[x[0] for x in results], curConfirms=[x[1] for x in results])
@app.route('/country_curconfirm')
def get_country_curconfirm():
mydb = MyDB('localhost', 'root', 'Aa183365', 'covid19_datas')
results = mydb.get_country_curConfirms() # results : [(), (), ...]
return jsonify(pub_date=results[0][2], provinces=[x[0] for x in results], curConfirms=[x[1] for x in results])
@app.route('/guangxi_curconfirm')
def get_guangxi_curconfirm():
mydb = MyDB('localhost', 'root', 'Aa183365', 'covid19_datas')
results = mydb.get_guangxi_curConfirms() # results : [(), (), ...]
return jsonify(pub_date=results[0][2], provinces=[x[0] for x in results], curConfirms=[x[1] for x in results])
@app.route('/henan_curconfirm')
def get_henan_curconfirm():
mydb = MyDB('localhost', 'root', 'Aa183365', 'covid19_datas')
results = mydb.get_henan_curConfirms() # results : [(), (), ...]
return jsonify(pub_date=results[0][2], provinces=[x[0] for x in results], curConfirms=[x[1] for x in results])
@app.route('/province_top5')
def get_province_topn():
mydb = MyDB('localhost', 'root', 'Aa183365', 'covid19_datas')
results = mydb.get_province_top5() # results : []
return jsonify(pub_date=results[0][4], privinces=[x[0] for x in results], curConfirms=[x[1] for x in results],confirmcount=[x[2] for x in results],curecount=[x[3] for x in results])
@app.route('/country_top10')
def get_country_top10():
mydb = MyDB('localhost', 'root', 'Aa183365', 'covid19_datas')
results = mydb.get_country_top10() # results : []
return jsonify(pub_date=results[0][4], privinces=[x[0] for x in results], curConfirms=[x[1] for x in results],confirmcount=[x[2] for x in results],curecount=[x[3] for x in results])
app.run()