首页 > 解决方案 > Heroku 在 Plotly Dash 网站上遵循 Basic Auth 示例时崩溃

问题描述

在遵循在 Heroku 上部署 Dash 应用程序示例之后,我将 app.py 更改为 Plotly Dash 网站上的基本身份验证示例。结果,我的 Heroku 网站崩溃了。如何使示例在 Heroku 上运行?

标签: authenticationherokuplotly-dash

解决方案


查看 Heroku 日志,我发现了两个错误:

  1. ModuleNotFoundError:没有名为“请求”的模块
  2. 未能在“应用程序”中找到属性“服务器”。

我安装了请求库,确保更新 requirements.txt。(不确定此步骤是否必要,但这是我修复的第一个错误。)在Basic Auth Example中,您会注意到server = app.server不存在,但存在于Deploying Dash Apps中。添加服务器信息后,一切正常:

    app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
    server = app.server

推荐阅读