繁体   English   中英

在服务器上找不到请求的 URL。 如果您手动输入 URL,请检查您的拼写并重试

[英]The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again

它显示与 root url 相关的 function ie ('/') 但如果我写 @app.route('/home') 它会给我那个错误

根据您的澄清评论,您的浏览器似乎正在访问您的应用服务器的先前版本。

我自己在使用 PyCharm IDE 时遇到过这个问题。 在 Windows 上,关闭这些旧版本服务器的方法是按Ctrl+Alt+DeleteCtrl+Shift+Esc (Windows 10) 查看正在运行的进程列表。 然后向下滚动,直到看到名为Python进程并将它们全部关闭。

我不知道是因为运行了其他一些 python 应用程序还是什么原因,但是当我是 Flask 的初学者时,我遇到了与您类似的错误。

我写了app.route('/')而不是@app.route('/') (我错过了@符号)。

查看您的代码是否属于这种情况。

你应该写@app.route('/home/')。 这为我解决了问题!

我最初尝试使用 @app.route("/hello") ,其中我定义的函数是 def hello(): return "some statement" 这给了我上述错误,我删除了 "/hello" 并尝试使用 "/ “这为我解决了这个问题。 ps(我在 pycharm 中做了这个,而 os 是 windows 10)

在为我的团队将旧Python Flask应用程序部署到Azure 应用服务后,我遇到了这个问题。

我收到错误:

未找到。 在服务器上找不到请求的 URL。 如果您手动输入了 URL,请检查您的拼写并重试。

这是我修复它的方法

问题是我输入的 URL 不正确。 显然,开发人员没有设置根路由,所以不是这样:

https://my-website.com

您必须指定所需资源的路径,因此我们将拥有:

https://my-website.com/my-desired-path

就这样

我对这个问题的解决方法:就是切换这个指令

if __name__ == "__main__":
     app.run(debug=True ,port=8080,use_reloader=False)

如下例所示

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')

到脚本的末尾(同一个例子):

 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 在服务器上找不到请求的 URL。 如果您手动输入 URL,请检查您的拼写并重试。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM