如何修复烧瓶应用程序中未找到错误的页面?
我是新来的烧瓶。我有一个网站,其中有许多页面正常工作。我只是尝试添加一个新的,它正在产生404错误。它似乎像所有其他页面一样设置,所以我不知道原因。这是app.py文件中的相关部分:
@app.route("/verbs")
def verbs():
return render_template('verbs.html', title="Verbing Out")
@app.route("/tobe")
def toBe():
return render_template('tobe.html', title="To Be Words")
@app.route("/strategies")
def strategies():
return render_template('strategies.html', title="Strategies for To Be Words")
称为动词的文件,tobe.html和straltagies.html在同一目录中。后两个工作很好。动词。html返回“找不到。在服务器上找不到请求的URL。如果您手动输入URL,请检查您的拼写并重试。”
所有文件都在模板目录中。这是目录的内容。
-rw-r--r--@ 1 Owner staff 7188 Jul 5 21:32 examples.html
-rw-r--r--@ 1 Owner staff 65 Jul 4 10:13 footer.html
-rw-r--r--@ 1 Owner staff 367 Jul 1 12:55 form.html
-rw-r--r--@ 1 Owner staff 122 Jul 4 10:13 header.html
-rw-r--r--@ 1 Owner staff 2833 Jul 7 06:42 home.html
-rw-r--r--@ 1 Owner staff 1537 Jul 4 09:31 layouts.html
-rw-r--r--@ 1 Owner staff 764 Jul 5 21:20 passive.html
-rw-r--r--@ 1 Owner staff 1656 Jul 1 12:55 results.html
-rw-r--r--@ 1 Owner staff 2657 Jul 7 06:47 strategies.html
-rw-r--r--@ 1 Owner staff 0 Jul 1 12:55 toBeForm.html
-rw-r--r--@ 1 Owner staff 2991 Jul 5 21:14 tobe.html
-rw-r--r--@ 1 Owner staff 2185 Jul 5 21:24 verbs.html
我正在尝试通过此导航菜单访问它们:
<li><a href="/verbs">Verbing Out</a></li>
<li><a href="/tobe">   To Be Verbs</a></li>
<li><a href="/strategies">   Strategies</a></li>
据我所知,这三个示例是并行设置的,因此我无法弄清楚为什么其中一个行为不同。我想念什么?
I'm new to Flask. I have a site with a number of pages that are working fine. I just tried to add a new one, and it's generating a 404 error. It seems to be set up like all the other pages, so I can't figure out why. Here's the relevant section from the app.py file:
@app.route("/verbs")
def verbs():
return render_template('verbs.html', title="Verbing Out")
@app.route("/tobe")
def toBe():
return render_template('tobe.html', title="To Be Words")
@app.route("/strategies")
def strategies():
return render_template('strategies.html', title="Strategies for To Be Words")
The files called verbs.html, tobe.html, and strategies.html are in the same directory. the latter two work just fine. verbs.html returns "Not Found. The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again."
All of the files are in the templates directory. Here are the contents of the directory.
-rw-r--r--@ 1 Owner staff 7188 Jul 5 21:32 examples.html
-rw-r--r--@ 1 Owner staff 65 Jul 4 10:13 footer.html
-rw-r--r--@ 1 Owner staff 367 Jul 1 12:55 form.html
-rw-r--r--@ 1 Owner staff 122 Jul 4 10:13 header.html
-rw-r--r--@ 1 Owner staff 2833 Jul 7 06:42 home.html
-rw-r--r--@ 1 Owner staff 1537 Jul 4 09:31 layouts.html
-rw-r--r--@ 1 Owner staff 764 Jul 5 21:20 passive.html
-rw-r--r--@ 1 Owner staff 1656 Jul 1 12:55 results.html
-rw-r--r--@ 1 Owner staff 2657 Jul 7 06:47 strategies.html
-rw-r--r--@ 1 Owner staff 0 Jul 1 12:55 toBeForm.html
-rw-r--r--@ 1 Owner staff 2991 Jul 5 21:14 tobe.html
-rw-r--r--@ 1 Owner staff 2185 Jul 5 21:24 verbs.html
I'm trying to access them through this navigation menu:
<li><a href="/verbs">Verbing Out</a></li>
<li><a href="/tobe"> To Be Verbs</a></li>
<li><a href="/strategies"> Strategies</a></li>
As far as I can see, the three examples are set up in parallel, so I can't figure out why one of them acts differently. What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一切都很简单。 Blask默认情况下在
模板
目录中查找模板,这就是为什么它看不到您的文件。将它们放入模板
目录中,它将起作用。如果我的解释似乎是舌头的,这是:
Everything is simple. Flask looks for templates in the
templates
directory by default, which is why it doesn't see your files. Put them in thetemplates
directory and it will work.If my explanation seemed tongue-tied, here is a piece of documentation: