我正在使用 recastai 编写 FB 机器人,我正在关注这个示例https://recast.ai/docs/api-reference/#request-text并且我编写了这段代码来分析文本
from flask import Flask
import recastai
app = Flask(__name__)
@app.route('/')
def home():
request = recastai.Request('TOKEN')
response = request.analyse_text('Hello')
return 'hello'
输出页面显示“内部服务器错误”并且错误日志显示导入错误,但是它仅在我添加响应行后出现
2017-12-03 05:41:16,767:
***************************************************
2017-12-03 06:48:14,534: Error running WSGI application
2017-12-03 06:48:14,555: requests.exceptions.ProxyError: HTTPSConnectionPool(host='api.recast.ai', port=443): Max retries exceeded with url: /v2/request (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden',)))
2017-12-03 06:48:14,555: File "/var/www/tarekhassan_pythonanywhere_com_wsgi.py", line 16, in <module>
2017-12-03 06:48:14,556: from hello import app as application
2017-12-03 06:48:14,556:
2017-12-03 06:48:14,556: File "/home/tarekhassan/bot/hello.py", line 7, in <module>
2017-12-03 06:48:14,556: def home():
2017-12-03 06:48:14,556:
2017-12-03 06:48:14,556: File "/home/tarekhassan/.local/lib/python3.5/site-packages/recastai/apis/request/analyse.py", line 27, in analyse_text
2017-12-03 06:48:14,556: headers={'Authorization': "Token {}".format(token)}
2017-12-03 06:48:14,556:
2017-12-03 06:48:14,556: File "/usr/local/lib/python3.5/dist-packages/requests/api.py", line 111, in post
2017-12-03 06:48:14,557: return request('post', url, data=data, json=json, **kwargs)
2017-12-03 06:48:14,557:
2017-12-03 06:48:14,557: File "/usr/local/lib/python3.5/dist-packages/requests/api.py", line 57, in request
2017-12-03 06:48:14,557: return session.request(method=method, url=url, **kwargs)
2017-12-03 06:48:14,557:
2017-12-03 06:48:14,557: File "/usr/local/lib/python3.5/dist-packages/requests/sessions.py", line 475, in request
2017-12-03 06:48:14,557: resp = self.send(prep, **send_kwargs)
2017-12-03 06:48:14,558:
2017-12-03 06:48:14,558: File "/usr/local/lib/python3.5/dist-packages/requests/sessions.py", line 585, in send
2017-12-03 06:48:14,558: r = adapter.send(request, **kwargs)
2017-12-03 06:48:14,558:
2017-12-03 06:48:14,558: File "/usr/local/lib/python3.5/dist-packages/requests/adapters.py", line 465, in send
2017-12-03 06:48:14,558: raise ProxyError(e, request=request)
2017-12-03 06:48:14,559: ***************************************************
2017-12-03 06:48:14,559: If you're seeing an import error and don't know why,
2017-12-03 06:48:14,559: we have a dedicated help page to help you debug:
2017-12-03 06:48:14,559: https://help.pythonanywhere.com/pages/DebuggingImportError/