flask - 在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
请帮助解决这个问题。我在这里做错了什么?
解决方案
可能可以用procfile解决:
web: gunicorn app.app:app
尽管为清楚起见,您可能希望将顶级app
文件夹重命名为不同的名称,但请使用:
web: gunicorn something.app:app
或者创建一个something/__init__.py
包含以下内容的文件:
from .app import app
然后只需有一个procfile:
web: gunicorn something:app
推荐阅读
- c# - 我如何“标记”用户发送的消息,而不仅仅是接收它,就好像它来自其他人一样?
- mongodb - 在 mongoDB 中查找未出现在其他文档中的电子邮件
- swift - 在空 NSSet 上迁移关系到一对多结果
- julia - Julia 中有某种空 IOStream 吗?
- java - EnumSet.copyOf 空集合抛出 IllegalArgumentException
- c# - 将一个 ViewModel 移动到另一个 ViewModel 时如何调用服务
- firebase - 用nodejs sdk编写的Firebase函数可以通过firestore规则吗?
- python-3.x - 如何捕捉 Google Video Intelligence DeadlineExceeded 异常?
- java - 如何将 java.util.random 转换为 int
- keras - Keras 中输入数据的规范化