在山核桃饼上用Gunicorn运行烧瓶

时间:2015-10-22 21:15:09

标签: python flask raspberry-pi gunicorn

我正试图用我的Raspberry pi上的gunicorn运行我的烧瓶应用程序。我已将路由器设置为端口转发localhost:5000。当我通过python manage.py runserver运行我的烧瓶应用程序时,这很有效。我可以在任何设备上使用我的浏览器并键入http://**.**.***.***:5000/,它将加载我的烧瓶应用程序。但是,当我尝试通过gunicorn运行应用程序时,我收到错误连接页面。我完全像flask documentation所说的那样操纵炮弹。如果我查看gunicorn的日志,我可以看到正在渲染的html。这是踢球者,当我在本地使用gunicorn运行应用程序时(gunicorn -w 2 -b localhost:5000 my_app:app),它运行得很好。我有最佳在线,我的路由器设置如下......

protocol -> all
port -> 5000
forward port to -> same as incoming port
host -> raspberrypi 
locate device by -> ipaddress

就像我说当我使用python内置的wsgi服务器时,这些设置在我的pi中运行得很好。当我在本地运行时,Gunicorn工作得很好,当我在浏览器中输入localhost:5000时,我可以看到我的应用程序,就在我在pi上设置它并尝试使用外部IP访问页面时,如果我不使用gunicorn外部IP工作得很好。我无法弄清楚。有什么想法吗?

1 个答案:

答案 0 :(得分:3)

你需要让Gunicorn听0.0.0.0(所有网络接口)。这意味着它将监听外部可访问的IP地址。

有关this post on ServerFaultlocalhost0.0.0.0之间差异的更多信息。

相关问题