【发布时间】:2021-06-08 09:04:31
【问题描述】:
使用 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 行,调用中 return self.wsgi_app(environ, start_response) wsgi_app 中的文件“C:\Users\Jayanth.virtualenvs\helloworld-CPu4KsHf\lib\site-packages\flask\app.py”,第 2073 行 响应 = self.handle_exception(e) wsgi_app 中的文件“C:\Users\Jayanth.virtualenvs\helloworld-CPu4KsHf\lib\site-packages\flask\app.py”,第 2070 行 响应 = 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 return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args) Webhook 中的文件“D:\ExcelSoft\venil\Cognitive-Behavioural-Chatbot-master\helloworld\web.py”,第 26 行 res = processRequest(req) 文件“D:\ExcelSoft\venil\Cognitive-Behavioural-Chatbot-master\helloworld\web.py”,第 36 行,在 processRequest print ("开始 processRequest...",req.get("result").get("action")) AttributeError: 'NoneType' 对象没有属性 'get'
我尝试过:http://localhost/webhook
【问题讨论】:
-
您还需要在
webhook_weather.py中显示代码。如果它没有/的路由,你会得到一个 404。 -
另外,您在第一个环境变量中有错字。这是
FLASK_ENV,而不是FASK_ENV。 -
是的,它是 FLASK_ENV ,拼写错误..
-
这些是应用路由,@app.route('/webhook', methods=['POST']) ; @app.route('/test', methods=['GET']) ;和 @app.route('/static_reply', methods=['POST']) 。
-
您之前链接的存储库中没有
helloworld/web.py。
标签: python