[英]The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again
it shows the function related to root url ie ('/') but if i write @app.route('/home') it gives me that error它显示与 root url 相关的 function ie ('/') 但如果我写 @app.route('/home') 它会给我那个错误
Based on your clarifying comments, it appears your browser is accessing a previous version of your app server.根据您的澄清评论,您的浏览器似乎正在访问您的应用服务器的先前版本。
I have run into this problem myself when using the PyCharm IDE.我自己在使用 PyCharm IDE 时遇到过这个问题。 On Windows, the way to shut down these old versions of the server is to press either
Ctrl+Alt+Delete
or Ctrl+Shift+Esc
(Windows 10) to view your list of running processes.在 Windows 上,关闭这些旧版本服务器的方法是按
Ctrl+Alt+Delete
或Ctrl+Shift+Esc
(Windows 10) 查看正在运行的进程列表。 Then scroll down until you see processes named Python
and shut them all down.然后向下滚动,直到看到名为
Python
进程并将它们全部关闭。
I don't know if it's due to some other python application running or something, but when I was a beginner in Flask I got a similar error to you.我不知道是因为运行了其他一些 python 应用程序还是什么原因,但是当我是 Flask 的初学者时,我遇到了与您类似的错误。
I wrote app.route('/')
instead of @app.route('/')
(I missed the @
symbol).我写了
app.route('/')
而不是@app.route('/')
(我错过了@
符号)。
See whether it's the case for your code.查看您的代码是否属于这种情况。
You should have written @app.route('/home/').你应该写@app.route('/home/')。 That fixed the problem for me!
这为我解决了问题!
I initially tried with @app.route("/hello") where the function I defined inside was def hello(): return "some statement" this gave me the error stated above, I removed "/hello" and tried with "/" this resolved the issue for me.我最初尝试使用 @app.route("/hello") ,其中我定义的函数是 def hello(): return "some statement" 这给了我上述错误,我删除了 "/hello" 并尝试使用 "/ “这为我解决了这个问题。 ps(I did this in pycharm and os is windows 10)
ps(我在 pycharm 中做了这个,而 os 是 windows 10)
I had this issue after deploying a legacy Python Flask application to Azure App Service for my team.在为我的团队将旧Python Flask应用程序部署到Azure 应用服务后,我遇到了这个问题。
I was getting the error:我收到错误:
Not Found.
未找到。 The requested URL was not found on the server.
在服务器上找不到请求的 URL。 If you entered the URL manually please check your spelling and try again.
如果您手动输入了 URL,请检查您的拼写并重试。
Here's how I fixed it :这是我修复它的方法:
The issue was that the URL I was entering wasn't the right one.问题是我输入的 URL 不正确。 Apparently, the developers did not set a root route, so instead of this:
显然,开发人员没有设置根路由,所以不是这样:
https://my-website.com
You will have to specify the path to the resource you want, so we will have:您必须指定所需资源的路径,因此我们将拥有:
https://my-website.com/my-desired-path
That's all就这样
My solution to this problem: is to switch this instruction我对这个问题的解决方法:就是切换这个指令
if __name__ == "__main__":
app.run(debug=True ,port=8080,use_reloader=False)
as in the example bellow如下例所示
from flask import Flask, render_template, request
app = Flask(__name__,template_folder="template")
@app.route("/")
def hello():
return render_template('index.html')
if __name__ == "__main__":
app.run(debug=True ,port=8080,use_reloader=False)
@app.route('/register', methods=['POST'])
def register():
query = request.form.get('query1')
selected = request.form.get('query')
if (not query or not selected):
return 'failure'
processed_text = query.upper()
return render_template('sucess.html')
to the end of your script (same example):到脚本的末尾(同一个例子):
from flask import Flask, render_template, request
app = Flask(__name__,template_folder="template")
@app.route("/")
def hello():
return render_template('index.html')
@app.route('/register', methods=['POST'])
def register():
query = request.form.get('query1')
selected = request.form.get('query')
if (not query or not selected):
return 'failure'
processed_text = query.upper()
return render_template('sucess.html')
if __name__ == "__main__":
app.run(debug=True ,port=8080,use_reloader=False)
你可能在 app.route('/') 之前错过了'@'
<div style = "text-align: center;"> <a href="{{ url_for('static',filename=path)}}"> <button class="slide_from_bottom button">check here </button> </a> </div>
Not Found The requested URL was not found on the server. Not Found 在服务器上找不到请求的 URL。 If you entered the URL manually please check your spelling and try again.
如果您手动输入 URL,请检查您的拼写并重试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.