Flask debug = True在通过uWSGI时不起作用 [英] Flask debug=True does not work when going through uWSGI
问题描述
我拥有它部署与uWSGI和nginx(我遵循这些说明 )
uwsgi -s /tmp/uwsgi.sock -w flask_file_name:app -H / path / to / virtual / env - -chmod-socket 666
但是当我得到一个错误,我没有得到任何调试信息浏览器或在uWSGI日志。
任何想法?
$ flask_file_name.py:$ / $>
from flask import烧瓶,make_response,响应,jsonify
导入json
app =烧瓶(__ name__)
app.debug = True
@ app.route(/)
def hello():
返回Hello World!
$ b $ if if __name__ =='__main__':
app.run()
根据 Flask邮件列表,你不能在Flags的调试选项中使用 uWSGI
,因为它不能在分叉环境中使用。
lockquote
你看到502,因为flask / werkzeug不会发送任何数据到web服务器
,所以nginx会返回502。 b
$ b
您可以使用uWSGI
中的--catch-exceptions选项来模拟调试器(但是请不要在生产中使用)
所以,你看到502s的原因就是因为这个。解决的办法是在执行时添加 - catch-exceptions
到 uWSGI
。
I call app.run(debug=True)
in my flask file.
and I have it deployed with uWSGI and nginx (I followed these instructions)
uwsgi -s /tmp/uwsgi.sock -w flask_file_name:app -H /path/to/virtual/env --chmod-socket 666
But when I get an error, I don't get any debug information in the browser or in the uWSGI log.
Any ideas?
flask_file_name.py:
from flask import Flask, make_response, Response, jsonify
import json
app = Flask(__name__)
app.debug = True
@app.route("/")
def hello():
return "Hello World!"
if __name__ == '__main__':
app.run()
According to the Flask mailing list you cannot use Flask's debug option with uWSGI
, because it's not to be used in a forking environment.
You see 502 because flask/werkzeug do not send any data to the webserver, so nginx will returns a 502.
You can emulate the debugger using --catch-exceptions option in uWSGI (but please do not do it in production)
So, the reason you're seeing 502s will be because of that. The fix would be to add --catch-exceptions
to uWSGI
on execution.
这篇关于Flask debug = True在通过uWSGI时不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!