首页 > 解决方案 > 在heroku上部署烧瓶应用程序时出错:无法在“应用程序”中找到属性“应用程序”

问题描述

我正在尝试在 heroku 上部署我非常简单的烧瓶应用程序,但是当我尝试访问我的 heroku 应用程序时,它给了我这个错误:An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.我从终端检查了日志,它说:Failed to find attribute 'app' in 'app'

代码

from flask import Flask

app = Flask(__name__)

@app.route('/')
def index():
    return "VatsalayKhobragade.me"

项目结构

*

简介

web: gunicorn app:app

要求.txt

click==7.1.2
Flask==1.1.2
gunicorn==20.0.4
itsdangerous==1.1.0
Jinja2==2.11.2
MarkupSafe==1.1.1
Werkzeug==1.0.1

请帮助解决这个问题。我在这里做错了什么?

标签: flaskherokuweb-deployment

解决方案


可能可以用procfile解决:

web: gunicorn app.app:app


尽管为清楚起见,您可能希望将顶级app文件夹重命名为不同的名称,但请使用:

web: gunicorn something.app:app

或者创建一个something/__init__.py包含以下内容的文件:

from .app import app

然后只需有一个procfile:

web: gunicorn something:app


推荐阅读