9 Star 1 Fork 2

lonelyway/MoviesAnalysingSystem

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
appV1.py 2.21 KB
一键复制 编辑 原始数据 按行查看 历史
lonelyinnovator 提交于 2022-06-22 11:20 . 整合数据分析和可视化
from flask import Flask,render_template,request
import sqlite3
from urllib import parse
app = Flask(__name__)
# @app.route('/index')
# def hello_world():
# return 'Hello World!'
#
# #获取字符串参数
# @app.route("/user/<name>")
# def welcom(name):
# return "你好,%s"%name
#
# #整形
# @app.route("/user/<int:id>")
# def welcom2(id):
# return "你好,%d 号"%id
# 登录界面
@app.route('/')
def login():
return render_template("home.html")
# 首页
@app.route('/home')
def home():
return render_template("home.html")
# 表格
@app.route('/sheet')
def sheet():
datalist = []
con = sqlite3.connect("test.db")
cur = con.cursor()
sql = "select * from testinfo"
data = cur.execute(sql)
for item in data:
datalist.append(item)
cur.close()
con.close()
return render_template("sheet.html",movies = datalist)
# 表格 接收来自特定国家的信息
@app.route('/sheet2')
def sheet2():
url = request.url
params = parse.parse_qs(parse.urlparse(url).query)
print(params['nation'])
country = params['nation']
country = country[0]
# print(str(cc))
# cc = request.form.get("nation", type=str, default='中国')
# print(str(cc))
datalist = []
con = sqlite3.connect("test.db")
cur = con.cursor()
sql = "select * from testinfo where nation = " + "'"+str(country) + "'"
data = cur.execute(sql)
for item in data:
datalist.append(item)
cur.close()
con.close()
return render_template("sheet.html",movies = datalist)
# 图表
@app.route('/chart')
def chart():
datalist = [] #国家 + 每个国家的电影数量
# num = [] #每个国家的电影数量
con = sqlite3.connect("test.db")
cur = con.cursor()
sql = "select nation,count(nation) from testinfo group by nation"
data = cur.execute(sql)
for item in data:
datalist.append(item)
# num.append(item[1])
cur.close()
con.close()
return render_template("chart.html",datalist = datalist)
# 词云
@app.route('/wordCloud')
def wordCloud():
return render_template("home.html")
# 用户
@app.route('/user')
def user():
return render_template("home.html")
if __name__ == '__main__':
app.run()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/lonelyinnovator/movies-analysing-system.git
git@gitee.com:lonelyinnovator/movies-analysing-system.git
lonelyinnovator
movies-analysing-system
MoviesAnalysingSystem
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385