在Apache上运行Flask有困难。按照here的指示设置mod uwsgi。我把我想要的python代码放入/var/www/TDAA_reminder/TDAA_reminder/__init__.py
。如果我通过sudo python __init__.py
手动运行代码并使用ngrok,它将收到twilio帖子,因此我知道代码正在工作。但不会和国防部合作。这个系统已经自动生成了__init__.pyc
,所以我觉得它可能有点工作,但是我还不知道下一步在哪里调试。我已经多次重新加载并重新启动apache。为了确保我没有弄坏任何东西。谢谢!在
本教程中的目录结构与我预期的有点不同,因此:
|--------TDAA_reminder
|----------------TDAA_reminder
|-----------------------static
|-----------------------templates
|-----------------------TDAAenv
|-----------------------__init__.py
|----------------flaskapp.wsgi
twilio中的错误是11200 HTTP retrieval failure
:
我的钩子指向http://andrewtclaus.com/TDAA_reminder
。在
摘录自/var/www/TDAA_reminder/TDAA_reminder/__init__.py
:
app = Flask(__name__)
@app.route('/TDAA_reminder', methods=['POST'])
def TDAA_reminder():
/etc/apache2/sites-available/TDAA_reminder.conf
:
<VirtualHost *:80>
ServerName AndrewTClaus.com
ServerAdmin admin@andrewtclaus.com
WSGIScriptAlias / /var/www/TDAA_reminder/TDAA_reminder.wsgi
<Directory /var/www/TDAA_reminder/TDAA_reminder/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/TDAA_reminder/TDAA_reminder/static
<Directory /var/www/TDAA_reminder/TDAA_reminder/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
/var/www/TDAA_reminder/TDAA_reminder.wsgi
:
#!/usr/bin/python
activate_this = '/var/www/TDAA_reminder/TDAA_reminder/TDAAenv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/TDAA_reminder/")
from TDAA_reminder import app as application
Apache错误代码:
[Sat Sep 03 01:53:23.598479 2016] [:error] [pid 17691] [client 192.0.101.226:16488] mod_wsgi (pid=17691): Target WSGI script '/var/www/TDAA_reminder/TDAA_reminder.wsgi' cannot be loaded as Py$
[Sat Sep 03 01:53:23.598508 2016] [:error] [pid 17691] [client 192.0.101.226:16488] mod_wsgi (pid=17691): Exception occurred processing WSGI script '/var/www/TDAA_reminder/TDAA_reminder.wsgi'.
[Sat Sep 03 01:53:23.598526 2016] [:error] [pid 17691] [client 192.0.101.226:16488] Traceback (most recent call last):
[Sat Sep 03 01:53:23.598542 2016] [:error] [pid 17691] [client 192.0.101.226:16488] File "/var/www/TDAA_reminder/TDAA_reminder.wsgi", line 11, in <module>
[Sat Sep 03 01:53:23.598565 2016] [:error] [pid 17691] [client 192.0.101.226:16488] from TDAA_reminder import app as application
[Sat Sep 03 01:53:23.598574 2016] [:error] [pid 17691] [client 192.0.101.226:16488] File "/var/www/TDAA_reminder/TDAA_reminder/__init__.py", line 37, in <module>
[Sat Sep 03 01:53:23.598639 2016] [:error] [pid 17691] [client 192.0.101.226:16488] flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)
[Sat Sep 03 01:53:23.598658 2016] [:error] [pid 17691] [client 192.0.101.226:16488] AttributeError: 'TwilioRestClient' object has no attribute 'flow_from_clientsecrets'
[Sat Sep 03 01:57:16.917248 2016] [:error] [pid 17688] [client 54.165.223.88:40658] mod_wsgi (pid=17688): Target WSGI script '/var/www/TDAA_reminder/TDAA_reminder.wsgi' cannot be loaded as Py$
[Sat Sep 03 01:57:16.917277 2016] [:error] [pid 17688] [client 54.165.223.88:40658] mod_wsgi (pid=17688): Exception occurred processing WSGI script '/var/www/TDAA_reminder/TDAA_reminder.wsgi'.
[Sat Sep 03 01:57:16.917308 2016] [:error] [pid 17688] [client 54.165.223.88:40658] Traceback (most recent call last):
[Sat Sep 03 01:57:16.917324 2016] [:error] [pid 17688] [client 54.165.223.88:40658] File "/var/www/TDAA_reminder/TDAA_reminder.wsgi", line 11, in <module>
[Sat Sep 03 01:57:16.917346 2016] [:error] [pid 17688] [client 54.165.223.88:40658] from TDAA_reminder import app as application
[Sat Sep 03 01:57:16.917370 2016] [:error] [pid 17688] [client 54.165.223.88:40658] File "/var/www/TDAA_reminder/TDAA_reminder/__init__.py", line 37, in <module>
[Sat Sep 03 01:57:16.917384 2016] [:error] [pid 17688] [client 54.165.223.88:40658] flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)
[Sat Sep 03 01:57:16.917400 2016] [:error] [pid 17688] [client 54.165.223.88:40658] AttributeError: 'TwilioRestClient' object has no attribute 'flow_from_clientsecrets'
调试相关节选:
SCOPES = ('https://www.googleapis.com/auth/calendar')
store = file.Storage('cal_auth.json')
creds = store.get()
if not creds or creds.invalid:
flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)
creds = tools.run_flow(flow, store, flags) \
if flags else tools.run(flow, store)
CAL = build('calendar', 'v3', http=creds.authorize(Http()))
通过以下讨论在评论中回答:
如果我读对了,
'TwilioRestClient' object has no attribute 'flow_from_clientsecrets'
但是当我读的时候python __init__.py
它就起作用了,而且我在使用ngrok隧道时没有出现错误,所以我很困惑为什么是错误?在相关问题 更多 >
编程相关推荐