python - 警告:不要在生产环境中使用开发服务器,并且在服务器上找不到请求的 URL
问题描述
使用 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 -
我无法打开应用程序页面。我会得到如下所示的页面:
未找到
在服务器上未找到请求的 URL。如果您手动输入了 URL,请检查您的拼写并重试。
当我运行 python 文件时,我得到了 AttributeError:
AttributeError:“NoneType”对象没有属性“get”
Traceback(最近一次调用最后一次)文件“C:\Users\Jayanth.virtualenvs\helloworld-CPu4KsHf\lib\site-packages\flask\app.py”,第 2088 行,调用返回 self.wsgi_app(environ, start_response) 文件“C:\Users\Jayanth.virtualenvs\helloworld-CPu4KsHf\lib\site-packages\flask\app.py”,第 2073 行,在 wsgi_app 响应 = self.handle_exception(e) 文件“C:\Users\Jayanth.virtualenvs \helloworld-CPu4KsHf\lib\site-packages\flask\app.py”,第 2070 行,在 wsgi_app 响应 = self.full_dispatch_request() 文件“C:\Users\Jayanth.virtualenvs\helloworld-CPu4KsHf\lib\site-packages \flask\app.py",第 1515 行,在 full_dispatch_request rv = self.handle_user_exception(e) 文件“C:\Users\Jayanth.virtualenvs\helloworld-CPu4KsHf\lib\site-packages\flask\app.py”中,行1513,在full_dispatch_request rv = self.dispatch_request() 文件“C:\Users\Jayanth.virtualenvs\helloworld-CPu4KsHf\lib\site-packages\flask\app.py",第 1499 行,在 dispatch_request 中返回 self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)文件“D:\ExcelSoft\venil\Cognitive-Behavioural-Chatbot-master\helloworld\web.py”,第 26 行,webhook res = processRequest(req) 文件“D:\ExcelSoft\venil\Cognitive-Behavioural-Chatbot- master\helloworld\web.py",第 36 行,在 processRequest print ("starting processRequest...",req.get("result").get("action")) AttributeError: 'NoneType' object has no attribute '得到'\ExcelSoft\venil\Cognitive-Behavioural-Chatbot-master\helloworld\web.py”,第 26 行,在 webhook res = processRequest(req) 文件“D:\ExcelSoft\venil\Cognitive-Behavioural-Chatbot-master\helloworld\ web.py",第 36 行,在 processRequest print ("starting processRequest...",req.get("result").get("action")) AttributeError: 'NoneType' object has no attribute 'get'\ExcelSoft\venil\Cognitive-Behavioural-Chatbot-master\helloworld\web.py”,第 26 行,在 webhook res = processRequest(req) 文件“D:\ExcelSoft\venil\Cognitive-Behavioural-Chatbot-master\helloworld\ web.py",第 36 行,在 processRequest print ("starting processRequest...",req.get("result").get("action")) AttributeError: 'NoneType' object has no attribute 'get'
我试过:http://localhost/webhook
解决方案
这些是应用程序路线,
@app.route('/webhook', methods=['POST'])
@app.route('/test', methods=['GET']
@app.route('/static_reply', methods=['POST'])
使用这些路由,尝试导航到 http://localhost/ 确实会返回 404;没有任何东西被路由到/
。
尝试 http://localhost/test 代替...
推荐阅读
- python - 获取 AttributeError:“list”对象在将 .log 文件格式转换为 .json 格式时没有属性“split”
- python - Python ruamel 不保留 yaml 中换行符的格式
- mysql - 累积和作为依赖子查询
- string - 如何在 Dart 中连接两个字符串?
- events - 失去对我的事件处理函数中所有内容的引用
- json - 将 json 从 ajax 传递到 laravel 控制器
- google-app-engine - 如何获取导出 Cloud Datastore 的结果详情?
- angular - Ionic 4 页面未在导航上更新
- html - 改变