双人结对作业疫情可视化(flask)
from flask import Flask, jsonify, render_template, request, json
import MysqlUtil
app = Flask(__name__)
@app.route("/")
def hello():
return render_template('TEXT.html')
@app.route("/q1")
def hellp():
return "helloworld"
@app.route("/c2")
def get_province():
res0 = []
res1 = []
res2 = []
res3 = []
for tup in MysqlUtil.get_province():
res0.append({"name": tup[0], "value": int(tup[1])})
res1.append({"name": tup[0], "value": int(tup[2])})
res2.append({"name": tup[0], "value": int(tup[3])})
res3.append({"name": tup[0], "value": int(tup[4])})
return jsonify({"confirm": res0, "suspect": res1, "heal": res2, "dead": res3})
@app.route("/c3", methods=['POST', 'GET'])
def get_area():
res0 = []
res1 = []
res2 = []
res3 = []
name = request.form.get("name")
for tup in MysqlUtil.get_area(name):
res0.append({"name": tup[0]+"市", "value": int(tup[1])})
res1.append({"name": tup[0]+"市", "value": int(tup[2])})
res2.append({"name": tup[0]+"市", "value": int(tup[3])})
res3.append({"name": tup[0]+"市", "value": int(tup[4])})
return jsonify({"confirm": res0, "suspect": res1, "heal": res2, "dead": res3})
if __name__ == '__main__':
app.run(debug=True, host='127.0.0.1', port='5000')