You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
from flask import Flask,request,render_template
|
|
|
|
import os
|
|
|
|
import pandas as pd
|
|
|
|
import math
|
|
|
|
|
|
|
|
|
|
|
|
csv_file='data/export.csv'
|
|
|
|
if os.path.exists(csv_file):
|
|
|
|
df=pd.read_csv(csv_file,encoding='utf-8')
|
|
|
|
else:
|
|
|
|
print('文件不存在')
|
|
|
|
|
|
|
|
app=Flask(__name__)
|
|
|
|
|
|
|
|
movies_page=25
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/')
|
|
|
|
def index():
|
|
|
|
total_movies = len(df)
|
|
|
|
return render_template("index.html",total_movies=total_movies)
|
|
|
|
@app.route('/index')
|
|
|
|
def index1():
|
|
|
|
total_movies = len(df)
|
|
|
|
return render_template("index.html",total_movies=total_movies)
|
|
|
|
@app.route('/movie')
|
|
|
|
def movie():
|
|
|
|
page=int(request.args.get('page',1))
|
|
|
|
|
|
|
|
start_idx=(page-1)*movies_page
|
|
|
|
end_idx=start_idx+movies_page
|
|
|
|
|
|
|
|
# 将数据转换为字典列表
|
|
|
|
movie_data=df.to_dict(orient='records')[start_idx:end_idx]
|
|
|
|
|
|
|
|
total_movies=len(df)
|
|
|
|
total_pages=math.ceil(total_movies/movies_page)
|
|
|
|
return render_template('movie.html',movie_data=movie_data,page=page,total_pages=total_pages)
|
|
|
|
@app.route('/score')
|
|
|
|
def score():
|
|
|
|
return render_template("score.html")
|
|
|
|
@app.route('/word')
|
|
|
|
def word():
|
|
|
|
return render_template("word.html")
|
|
|
|
if __name__=='__main__':
|
|
|
|
app.run(debug=True)
|