警告:不要在生产环境中使用开发服务器,并且在服务器上找不到请求的URL

2024-10-06 12:27:20 发布

您现在位置:Python中文网/ 问答频道 /正文

有了hello.py,它就可以使用“hello word”。 但当我运行应用程序(webhook_weather.py)时,它不工作,我得到以下错误: 我有

set FLASK_ENV=development
FLASK_APP= webhook_weather.py
flask run

(helloworld-x2biACXm) C:\Users\Jayanth\Desktop\helloworld>python webhook_weather.py
Starting app on port 80
• Serving Flask app 'webhook_weather' (lazy loading)
• Environment: development
• Debug mode: on
• Restarting with stat
Starting app on port 80
• Debugger is active!
• Debugger PIN: 119-286-619
• Running on all addresses.
WARNING: This is a development server. Do not use it in a production deployment.
• Running on http://192.168.43.87:80/ (Press CTRL+C to quit)

192.168.43.87 - - [04/Jun/2021 14:38:39] "GET / HTTP/1.1" 404 -

我无法打开应用程序页面。我将获得如下所示的页面:

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

当我运行python文件时,我得到了AttributeError:

AttributeError:“非类型”对象没有属性“get”

回溯(最近一次呼叫最后一次) 文件“C:\Users\Jayanth.virtualenvs\helloworld-CPu4KsHf\lib\site packages\flask\app.py”,第2088行,在调用中 返回self.wsgi_应用程序(环境,启动响应) wsgi_应用程序中的文件“C:\Users\Jayanth.virtualenvs\helloworld-CPu4KsHf\lib\site packages\flask\app.py”,第2073行 response=self.handle\u异常(e) wsgi_应用程序中的文件“C:\Users\Jayanth.virtualenvs\helloworld-CPu4KsHf\lib\site packages\flask\app.py”,第2070行 response=self.full\u dispatch\u request() 文件“C:\Users\Jayanth.virtualenvs\helloworld-CPu4KsHf\lib\site packages\flask\app.py”,第1515行,完整发送请求 rv=自身处理用户异常(e) 文件“C:\Users\Jayanth.virtualenvs\helloworld-CPu4KsHf\lib\site packages\flask\app.py”,第1513行,完全发送请求 rv=自我分派请求() 文件“C:\Users\Jayanth.virtualenvs\helloworld-CPu4KsHf\lib\site packages\flask\app.py”,第1499行,在调度请求中 返回self.sure_sync(self.view_函数[rule.endpoint])(**req.view_参数) 文件“D:\ExcelSoft\venil\Cognitive Behavior Chatbot master\helloworld\web.py”,第26行,在webhook中 res=处理请求(req) processRequest中第36行的文件“D:\ExcelSoft\venil\Cognitive Behavior Chatbot master\helloworld\web.py” 打印(“开始处理请求…”,请求获取(“结果”)。获取(“操作”)) AttributeError:“非类型”对象没有属性“get”

我试过:http://localhost/webhook


Tags: 文件pyapp应用程序flaskonlibpackages
1条回答
网友
1楼 · 发布于 2024-10-06 12:27:20

These are the app route,
@app.route('/webhook', methods=['POST'])
@app.route('/test', methods=['GET']
@app.route('/static_reply', methods=['POST'])

使用这些路线,尝试导航到http://localhost/ 确实会返回404;没有路由到/

试一试http://localhost/test 相反

相关问题 更多 >