Azure WebRole + Flask : AttributeError: 'module' object has no attribute 'wsgi_app'

标签 azure iis flask azure-web-roles

不像 Azure Flask Deployment - WSGI Interface问题,将 Flask 应用部署到 Azure Web 角色会引发以下问题。

AttributeError: 'module' object has no attribute 'wsgi_app'

这个错误是什么?

最佳答案

我终于明白了。

启动 .py 文件必须在 Flask 应用定义之后定义 wsgi_app

app = Flask(__name__)

# define for IIS module registration.
wsgi_app = app.wsgi_app

if __name__ == '__main__':
    app.run()

此外,{StartupModule}.wsgi_app 是在 Project Properties > Web > WSGI Handler 中定义的。

为了缩短试错时间,最好从新创建的 Azure WebRole Python 项目模板开始。

哇哦。花了一整天的时间。

关于Azure WebRole + Flask : AttributeError: 'module' object has no attribute 'wsgi_app' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39427398/

相关文章:

c# - AddApplicationInsightsTelemetry未注册ILoggingProvider

azure - 如何确保通过 Azure 服务总线队列接收所有消息?

python - 是否可以从正在运行的 Docker 容器中发送 HTTP 请求

python - 可选的 URL 变量

python - Flask如何在内部加载蓝图?

azure - 为 Azure Bing map 配置编程部署

azure - 搜索栏在 Chrome 中不工作

c# - 如何使用 C# 检测 IIS 版本?

c# - Web Api Controller 和线程池

asp.net - 允许匿名访问 IIS 中的单个文件