代码拉取完成,页面将自动刷新
from flask import Flask,render_template
import sqlite3
app = Flask(__name__)
@app.route('/')
def home():
return render_template("index.html")
@app.route('/index')
def home1():
# return render_template("index.html")
return home()
@app.route('/index.html')
def index():
return home()
@app.route('/movie')
def movie():
datalist = []
con=sqlite3.connect("movie.db")
cur=con.cursor()
sql = "select * from movie"
data = cur.execute(sql)
for item in data: #若执行后直接关掉数据库相应的数据也会消失
datalist.append(item)
cur.close()
con.close()
return render_template("movie.html",movies=datalist)
@app.route('/score')
def score():
datalist = []
score = [] #评分
num = [] #评分人数
con=sqlite3.connect("movie.db")
cur=con.cursor()
sql = "select score,count(score) from movie group by score"
data = cur.execute(sql)
for item in data: #若执行后直接关掉数据库相应的数据也会消失
score.append(item[0]) #str(item[0])
num.append(item[1])
cur.close()
con.close()
return render_template("score.html",score=score,num=num)
@app.route('/clouds')
def clouds():
return render_template("clouds.html")
@app.route('/team')
def team():
return render_template("team.html")
@app.route('/test')
def test():
return render_template("test.html")
if __name__ == '__main__':
app.run(host="0.0.0.0",debug=True)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。