commit 4a8737234cde95d8809ec9cc9f589908af5070ec
Author: Lebrabk <2656795153@qq.com>
Date: Tue May 5 21:35:25 2020 +0800
first commit
diff --git a/app.py b/app.py
new file mode 100644
index 0000000..012c518
--- /dev/null
+++ b/app.py
@@ -0,0 +1,175 @@
+from flask import Flask,render_template,request,redirect
+from flask_sqlalchemy import SQLAlchemy
+from sqlalchemy import func
+
+app = Flask(__name__)
+app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:265679@127.0.0.1:3306/pandemic'
+db=SQLAlchemy(app)
+
+class China(db.Model):
+ date=db.Column(db.Date,primary_key=True)
+ total_confirmed=db.Column(db.Integer,nullable=False)
+ new_confirmed=db.Column(db.Integer,nullable=False)
+ active_cases=db.Column(db.Integer,nullable=False)
+ imported_cases=db.Column(db.Integer,nullable=False)
+ # symptomless_cases=db.Column(db.Integer,nullable=False)
+ recovered=db.Column(db.Integer,nullable=False)
+ new_recovered=db.Column(db.Integer,nullable=False)
+ deaths=db.Column(db.Integer,nullable=False)
+ new_deaths=db.Column(db.Integer,nullable=False)
+#创建世界的疫情数据表
+class World(db.Model):
+ date=db.Column(db.String(255),primary_key=True)
+ country=db.Column(db.String(255),primary_key=True)
+ country_name=db.Column(db.String(255))
+ region=db.Column(db.String(255))
+ deaths=db.Column(db.Integer,nullable=False)
+ cumulative_deaths=db.Column(db.Integer,nullable=False)
+ confirmed=db.Column(db.Integer,nullable=False)
+ cumlative_confirmed=db.Column(db.Integer,nullable=False)
+#创建中国省份的相关信息表
+class provinces_info(db.Model):
+ province_name=db.Column(db.String(50),primary_key=True)
+##创建市的信息表(省市的从属关系)
+class cities_info(db.Model):
+ city_name=db.Column(db.String(50),primary_key=True)
+ province_name=db.Column(db.String(50),db.ForeignKey('provinces_info.province_name'))
+#创建区的相关信息,包含区和市的从属关系
+class districts_info(db.Model):
+ district_name=db.Column(db.String(50),primary_key=True)
+ city_name=db.Column(db.String(50),db.ForeignKey('cities_info.city_name'))
+ provinces_name=db.Column(db.String(50),db.ForeignKey('provinces_info.province_name'))
+#创建武汉病区的相关信息
+class community_info(db.Model):
+ id=db.Column(db.Integer,primary_key=True,autoincrement=True)
+ district_name=db.Column(db.String(50),db.ForeignKey('districts_info.district_name'))
+ address=db.Column(db.String(50))
+#创建医院的相关信息
+class hospitals_info(db.Model):
+ hospital_name=db.Column(db.String(50),primary_key=True)
+ district_name=db.Column(db.String(50),db.ForeignKey('districts_info.district_name'))
+ capacity=db.Column(db.Integer)
+ test=db.Column(db.Integer)
+ confirmed = db.Column(db.Integer)
+ rate=db.Column(db.Float)
+class patients_info(db.Model):
+ id=db.Column(db.Integer,primary_key=True,autoincrement=True)
+ date=db.Column(db.Date)
+ condition=db.Column(db.String(30))
+ district=db.Column(db.String(30))
+#创建省一级的疫情相关信息province_data
+class province_data(db.Model):
+ date = db.Column(db.Date, primary_key=True)
+ # province_name = db.Column(db.String(50),db.ForeignKey('provinces_info.province_name'),primary_key=True)
+ province_name = db.Column(db.String(50), primary_key=True)
+ total_confirmed = db.Column(db.Integer, nullable=False)
+ new_confirmed=db.Column(db.Integer, nullable=False)
+ active_cases = db.Column(db.Integer, nullable=False)
+ imported_cases = db.Column(db.Integer, nullable=False)
+ # symptomless_cases = db.Column(db.Integer, nullable=False)
+ recovered = db.Column(db.Integer, nullable=False)
+ deaths = db.Column(db.Integer, nullable=False)
+#创建市一级的疫情相关信息city_data
+class city_data(db.Model):
+ date = db.Column(db.Date, primary_key=True)
+ # province_name = db.Column(db.String(50), db.ForeignKey('provinces_info.province_name'))
+ # city_name = db.Column(db.String(50), db.ForeignKey('cities_info.city_name'),primary_key=True)
+ province_name = db.Column(db.String(50),primary_key=True)
+ city_name = db.Column(db.String(50),primary_key=True)
+ total_confirmed = db.Column(db.Integer, nullable=False)
+ active_cases = db.Column(db.Integer, nullable=False)
+ recovered = db.Column(db.Integer, nullable=False)
+ deaths = db.Column(db.Integer, nullable=False)
+class wuhan_data(db.Model):
+ date = db.Column(db.Date, primary_key=True)
+ district = db.Column(db.String(50),primary_key=True)
+ confirmed = db.Column(db.Integer, nullable=False)
+# @app.route("/select")
+# def selectAll():
+# china = China.query.all()
+# return render_template("china.html",china = china)
+
+@app.route('/')
+def cover():
+ return render_template('cover.html')
+
+@app.route("/china/")
+def china():
+ china = China.query.order_by(China.date.desc()).all()
+ return render_template("china.html",china = china)
+
+@app.route("/province/")
+def province():
+ date=request.args.get("date")
+ pro=province_data.query.filter_by(date=date).order_by(province_data.total_confirmed.desc()).all()
+ return render_template("province.html",pro = pro)
+
+@app.route("/city/")
+def city():
+ date = request.args.get("date")
+ pro_name=request.args.get("pro_name")
+ cit = city_data.query.filter_by(date=date,province_name=pro_name).order_by(city_data.total_confirmed.desc()).all()
+ return render_template("city.html",cit = cit)
+
+@app.route("/world/")
+def world():
+ world =db.session.query(World.date,
+ func.sum(World.cumlative_confirmed),
+ func.sum(World.confirmed),
+ func.sum(World.cumulative_deaths),
+ func.sum(World.deaths),).group_by('date').order_by(World.date.desc()).all()
+ return render_template("world.html",world=world)
+
+@app.route("/region/")
+def region():
+ date=request.args.get("date")
+ reg =db.session.query(World.date,
+ World.region,
+ func.sum(World.cumlative_confirmed),
+ func.sum(World.confirmed),
+ func.sum(World.cumulative_deaths),
+ func.sum(World.deaths)).filter_by(date=date).group_by('region').all()
+ return render_template("region.html",reg=reg)
+
+@app.route("/country/")
+def country():
+ date=request.args.get("date")
+ region=request.args.get("region")
+ coun =World.query.filter_by(date=date,region=region).order_by(World.cumlative_confirmed.desc()).all()
+ return render_template("country.html",coun=coun)
+@app.route("/hospitals/")
+def hospitals():
+ hosp=hospitals_info.query.order_by(hospitals_info.capacity).all()
+ return render_template("hospitals.html",hosp=hosp)
+
+@app.route("/wuhan/")
+def wuhan():
+ wu=wuhan_data.query.order_by(wuhan_data.date.desc()).all()
+ return render_template("wuhan.html",wuhan=wu)
+
+@app.route("/patients/")
+def patients():
+ pat=db.session.query(patients_info.district,
+ patients_info.condition,
+ func.count(patients_info.id)
+ ).group_by('condition','district').order_by(patients_info.district.desc()).all()
+ return render_template("patients.html",pat=pat)
+
+@app.route("/patient_detail/")
+def patient_detail():
+ district=request.args.get('district')
+ condition=request.args.get('condition')
+ pa = db.session.query(patients_info.date,
+ patients_info.district,
+ patients_info.condition,
+ func.count(patients_info.id)
+ ).filter_by(district=district,condition=condition)\
+ .group_by('date').order_by(patients_info.date.desc()).all()
+ return render_template("patient_detail.html",pat=pa)
+@app.route("/hospital_detail/")
+def hospital_detail():
+ district=request.args.get('district')
+ hosp = hospitals_info.query.filter_by(district_name=district).order_by(hospitals_info.district_name).all()
+ return render_template("hospital_detail.html", hosp=hosp)
+if __name__ == '__main__':
+ app.run(debug=True)
diff --git a/static/Coronavirus52.jpg b/static/Coronavirus52.jpg
new file mode 100644
index 0000000..2ee2535
Binary files /dev/null and b/static/Coronavirus52.jpg differ
diff --git a/static/aaa.png b/static/aaa.png
new file mode 100644
index 0000000..ef12896
Binary files /dev/null and b/static/aaa.png differ
diff --git a/static/cover.jpg b/static/cover.jpg
new file mode 100644
index 0000000..f6be8c4
Binary files /dev/null and b/static/cover.jpg differ
diff --git a/static/images (1).jpg b/static/images (1).jpg
new file mode 100644
index 0000000..86a380d
Binary files /dev/null and b/static/images (1).jpg differ
diff --git a/static/images.jpg b/static/images.jpg
new file mode 100644
index 0000000..c684c78
Binary files /dev/null and b/static/images.jpg differ
diff --git a/static/timg.jpg b/static/timg.jpg
new file mode 100644
index 0000000..dc180fe
Binary files /dev/null and b/static/timg.jpg differ
diff --git a/static/wuhan.jpg b/static/wuhan.jpg
new file mode 100644
index 0000000..358dcb2
Binary files /dev/null and b/static/wuhan.jpg differ
diff --git a/templates/china.html b/templates/china.html
new file mode 100644
index 0000000..1f1a16a
--- /dev/null
+++ b/templates/china.html
@@ -0,0 +1,95 @@
+
+
+
+
+
+ 国内疫情数据
+
+
+