我正在尝试将另一个视图添加到我的Flask应用程序中。我的app/views.py文件看起来像这样:
from flask import render_template
from app import app
from helpfulFunctions import *
def getRankingList():
allPlayers = main()
return allPlayers
def displayLimitedNumberOfPlayers(limit):
allPlayers = main()
allPlayers[0] = limitPlayers(allPlayers[0], limit)
allPlayers[1] = limitPlayers(allPlayers[1], limit)
return allPlayers
@app.route("/")
@app.route("/index")
def index():
rankingList = getRankingList()
return render_template('index.html', title='Home', rankingList = rankingList)
@app.route("/top100")
def top100():
rankingList = displayLimitedNumberOfPlayers(100)
return render_template('top100.html', rankingList = rankingList)
if __name__ == '__main__':
app.run(debug=True)
我试图模仿Miguel Grinberg教程中如何定义/
和/index
路由的方法。我在我的模板文件夹中创建了一个名为top100.html
的视图,其中也包含index.html
文件。然而,当我尝试访问localhost:5000/top100.html
时,我收到以下错误信息:
Not Found
The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
看起来 Flask 认为这个 URL 没有与之关联的视图……但我不确定为什么。
你有什么想法吗?
感谢帮助, bclayman
localhost:5000/top100
- itzMEonTV