【发布时间】:2021-12-14 00:45:44
【问题描述】:
我一直在按照 DigitalOcean 教程 (https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-18-04) 的大纲在 nginx/ubuntu 上部署烧瓶应用程序,并尝试部署 Dash 应用程序。
尝试使用命令 gunicorn --bind 0.0.0.0:5000 wsgi:app 时出现错误:Application object must be callable
我调用应用的方式是:
wsgi.py
from __init__ import app
if __name__ == "__main__":
app.run_server()
和:
__init__.py
#code
if __name__ == '__main__':
app.run_server(port=5000,host='0.0.0.0',debug=True)
应用程序本身在 app.py 中声明(遵循 Dash 教程中的多页模板)
app.py
import dash
app = dash.Dash(__name__, suppress_callback_exceptions=True)
server = app.server
当我使用 python3 wsgi.py 启动应用程序时,它在本地主机上运行,但由于某种原因我无法通过 IP:5000 访问它。
我怀疑 gunicorn 命令需要修改为引用服务器,而不仅仅是 wsgi:app,但我不确定正确的格式是什么。
【问题讨论】:
标签: ubuntu nginx flask digital-ocean plotly-dash