1 Star 0 Fork 1

土生土长/COVID-19-NLP-vis

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
server.py 2.65 KB
一键复制 编辑 原始数据 按行查看 历史
云微 提交于 2020-06-04 09:30 . update readme;
from random import randrange
from flask.json import jsonify
from flask import Flask, render_template
from flask import request
import pandas as pd
from pyecharts import options as opts
from pyecharts.charts import Line
from scripts.mapchina import render_mapcountChina
from scripts.mapworld import render_mapcountWorld
from scripts.lineCountry import render_lines
from scripts.jiebafenci import render_wordcloud
from scripts.weiboAnalyse import weiboWordcloud
n = "dataSets\\countrydata.csv"
data = pd.read_csv(n)
date_list = list(data[data['countryName'] == '中国']['dateId'])
countrylist = list(data[data['dateId'] == 20200412]['countryName'])
countrylist = ['中国']+countrylist
#print(date_list)
#print(countrylist)
app = Flask(__name__, static_folder="templates")
@app.route("/")
def index():
return render_template("index.html",cates = countrylist)
@app.route("/document")
def document():
return render_template("README.html")
@app.route("/nlp")
def nlpNotebook():
return render_template("NLP.html")
@app.route("/analyse")
def anaNotebook():
return render_template("analyse.html")
@app.route("/worldmap",methods=['POST', 'GET'])
def get_world_map():
if request.method == 'GET':
maptype = int(request.args.get('type', ''))
i = int(request.args.get('index', ''))
print(maptype)
print(i)
return render_mapcountWorld(date_list[int(i)],maptype).dump_options_with_quotes()
@app.route("/chinamap",methods=['POST', 'GET'])
def get_china_map():
if request.method == 'GET':
maptype = int(request.args.get('type', ''))
i = int(request.args.get('index', ''))
print(maptype)
print(i)
return render_mapcountChina(date_list[int(i)],maptype).dump_options_with_quotes()
@app.route("/lines")
def get_line_chart():
return render_lines('中国').dump_options_with_quotes()
@app.route("/wordcloud",methods=['POST', 'GET'])
def get_word_chart():
if request.method == 'GET':
i = request.args.get('value', '')
if not i:
i = 0
print(i)
return render_wordcloud(i).dump_options_with_quotes()
@app.route("/weiboCloud",methods=['POST', 'GET'])
def get_weibo_chart():
if request.method == 'GET':
i = request.args.get('value', '')
if not i:
i = 0
print(i)
return weiboWordcloud(i).dump_options_with_quotes()
@app.route('/changecountry',methods=['POST', 'GET'])
def changeCountry():
if request.method == 'GET':
selectCountry = request.args.get('value', '')
print(selectCountry)
return render_lines(selectCountry).dump_options_with_quotes()
if __name__ == "__main__":
app.run()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/opopi/COVID-19-NLP-vis.git
git@gitee.com:opopi/COVID-19-NLP-vis.git
opopi
COVID-19-NLP-vis
COVID-19-NLP-vis
master

搜索帮助

Cb406eda 1850385 E526c682 1850385