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 @@ + + + + + + 国内疫情数据 + + +
+
+照片 +
+ 返回主页 +
+ + +
+
+ +
+ + + + + + + + + + + + + + + + {% for item in china %} + + + + + + + + + + + + + + {% endfor %} + +
时间总确诊人数新确诊人数现有确诊境外输入治愈人数新增治愈人数死亡人数新增死亡人数详细信息
{{item.date}}{{item.total_confirmed}}{{item.new_confirmed}}{{item.active_cases}}{{item.imported_cases}}{{item.recovered}}{{item.new_recovered}}{{item.deaths}}{{item.new_deaths}}各省信息
+
+
+ + + \ No newline at end of file diff --git a/templates/city.html b/templates/city.html new file mode 100644 index 0000000..01049c3 --- /dev/null +++ b/templates/city.html @@ -0,0 +1,87 @@ + + + + + 各市疫情数据 + + + +
+
+照片 +
+ 返回主页 +
+ + +
+
+ +
+ + + + + + + + + +{# #} + + + + {% for item in cit %} + + + + + + + + + + {% endfor %} + +
时间省份城市累计确诊现有确诊治愈人数死亡人数详细信息
{{item.date}}{{item.province_name}}{{item.city_name}}{{item.total_confirmed}}{{item.active_cases}}{{item.recovered}}{{item.deaths}}
+ + + \ No newline at end of file diff --git a/templates/country.html b/templates/country.html new file mode 100644 index 0000000..d845ffd --- /dev/null +++ b/templates/country.html @@ -0,0 +1,91 @@ + + + + + Global information + + + +
+
+照片 +
+ return home page +
+ +
+
+ +
+ + + + + + + + + + + + + + + + {% for item in coun %} + + + + + + + + +{# #} + + {% endfor %} + +
dateregioncountrycumlative_confirmednew_confirmedcumulative_deathsnew_deaths
{{item.date}}{{item.region}}{{item.country_name}}{{item.cumlative_confirmed}}{{item.confirmed}}{{item.cumulative_deaths}}{{item.deaths}}country's information
+
+
+ + + \ No newline at end of file diff --git a/templates/cover.html b/templates/cover.html new file mode 100644 index 0000000..3c81823 --- /dev/null +++ b/templates/cover.html @@ -0,0 +1,35 @@ + + + + + 疫情数据库大作业 + + + +
+照片 +
+ + +
+

国内疫情

+

国外疫情

+

武汉疫情

+
+ 照片 +
+

武汉医院信息

+

武汉病患信息

+
+ + \ No newline at end of file diff --git a/templates/hospital_detail.html b/templates/hospital_detail.html new file mode 100644 index 0000000..aef9a0e --- /dev/null +++ b/templates/hospital_detail.html @@ -0,0 +1,85 @@ + + + + + 该区医院信息 + + + +
+
+
+ 返回主页 +
+ + +
+
+ +
+ + + + + + + + + +{# #} + + + + {% for item in hosp %} + + + + + + + + + {% endfor %} + +
医院名称区名床位数量检测人数确诊人数确诊比例详细信息
{{item.hospital_name}}{{item.district_name}}{{item.capacity}}{{item.test}}{{item.confirmed}}{{item.rate}}%
+ + + \ No newline at end of file diff --git a/templates/hospitals.html b/templates/hospitals.html new file mode 100644 index 0000000..462c064 --- /dev/null +++ b/templates/hospitals.html @@ -0,0 +1,86 @@ + + + + + 武汉市医院信息 + + + +
+
+照片 +
+ 返回主页 +
+ + +
+
+ +
+ + + + + + + + + +{# #} + + + + {% for item in hosp %} + + + + + + + + + {% endfor %} + +
医院名称区名床位数量检测人数确诊人数确诊比例详细信息
{{item.hospital_name}}{{item.district_name}}{{item.capacity}}{{item.test}}{{item.confirmed}}{{item.rate}}%
+ + + \ No newline at end of file diff --git a/templates/patient_detail.html b/templates/patient_detail.html new file mode 100644 index 0000000..b0a5136 --- /dev/null +++ b/templates/patient_detail.html @@ -0,0 +1,89 @@ + + + + + 各区病患详细信息 + + + +
+
+照片 +
+ 返回主页 +
+ + +
+
+ +
+ + + + + + + +{# #} +{# #} + + + + + {% for item in pat %} + + + + + +{# #} +{# #} +{# #} +{# #} + + + {% endfor %} + +
时间区名病情人数确诊人数确诊比例
{{item[0]}}{{item[1]}}{{item[2]}}{{item[3]}}{{item[3]}}{{item.confirmed}}{{item.rate}}%详细信息
+ + + \ No newline at end of file diff --git a/templates/patients.html b/templates/patients.html new file mode 100644 index 0000000..cf7523f --- /dev/null +++ b/templates/patients.html @@ -0,0 +1,94 @@ + + + + + 各区病患信息 + + + +
+
+照片 +
+ 返回主页 +
+ + +
+
+ +
+ + + +{# #} + + + +{# #} +{# #} + + + + + + {% for item in pat %} + +{# 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))#} + + + +{# #} +{# #} +{# #} + + + + + {% endfor %} + +
时间区名病情人数确诊人数确诊比例详细信息医院信息
{{item[0]}}{{item[1]}}{{item[2]}}{{item[3]}}{{item.confirmed}}{{item.rate}}%详细信息医院信息
+ + + \ No newline at end of file diff --git a/templates/province.html b/templates/province.html new file mode 100644 index 0000000..801285e --- /dev/null +++ b/templates/province.html @@ -0,0 +1,91 @@ + + + + + 各省疫情数据 + + + +
+
+照片 +
+ 返回主页 +
+ + +
+
+ +
+ + + + + + + + + + + + + + + {% for item in pro %} + + + + + + + + + + + + + {% endfor %} + +
时间省份累计确诊新增确诊现有确诊境外输入治愈人数死亡人数详细信息
{{item.date}}{{item.province_name}}{{item.total_confirmed}}{{item.new_confirmed}}{{item.active_cases}}{{item.imported_cases}}{{item.recovered}}{{item.deaths}}省内信息
+ + + \ No newline at end of file diff --git a/templates/region.html b/templates/region.html new file mode 100644 index 0000000..009273d --- /dev/null +++ b/templates/region.html @@ -0,0 +1,88 @@ + + + + + Global information + + + +
+ + +
+
+ +
+ + + + + + + + + + + + + + {% for item in reg %} + + + + + + + + + + {% endfor %} + +
dateregioncumlative_confirmedconfirmedcumulative_deathsdeathsMore information
{{item[0]}}{{item[1]}}{{item[2]}}{{item[3]}}{{item[4]}}{{item[5]}}country's information
+
+
+ + + \ No newline at end of file diff --git a/templates/world.html b/templates/world.html new file mode 100644 index 0000000..dd3dc1d --- /dev/null +++ b/templates/world.html @@ -0,0 +1,87 @@ + + + + + Global information + + + +
+ + +
+
+ +
+ + + + + + + + + + + + + {% for item in world %} + + + + + + + + + + {% endfor %} + +
datecumlative_confirmednew_confirmedcumulative_deathsnew_deathsMore information
{{item[0]}}{{item[1]}}{{item[2]}}{{item[3]}}{{item[4]}}region's information
+
+
+ + + \ No newline at end of file diff --git a/templates/wuhan.html b/templates/wuhan.html new file mode 100644 index 0000000..bf4aadc --- /dev/null +++ b/templates/wuhan.html @@ -0,0 +1,87 @@ + + + + + 各市疫情数据 + + + +
+
+照片 +
+ 返回主页 +
+ + +
+
+ +
+ + + + + +{# #} +{# #} +{# #} +{# #} +{# #} + + + + {% for item in wuhan %} + + + + +{# #} +{# #} +{# #} +{# #} + + {% endfor %} + +
时间区名确诊人数累计确诊现有确诊治愈人数死亡人数详细信息
{{item.date}}{{item.district}}{{item.confirmed}}{{item.total_confirmed}}{{item.active_cases}}{{item.recovered}}{{item.deaths}}
+ + + \ No newline at end of file