python - Heroku在部署python Flask Web应用程序时获取=错误代码= H10
问题描述
我正在尝试在 heroku 中部署我的第一个烧瓶应用程序。完全按照heroku文档中提到的步骤进行操作。但它抛出应用程序错误,如下所示
2021-07-18T12:55:34.315320+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=eflask-simple-app.herokuapp.com request_id=30d3a699-6f05-4783-a5f5-40c9717af881 fwd="117.213.244.13" dyno= connect= service= status=503 bytes= protocol=https
项目结构
app
main.py
Pipfile
Pipfile.lock
Procfile
requirements.txt
runtime.txt
wsgi.py
wsgi.py 文件
from app.main import app
import os
port = int(os.environ.get("PORT", 5000))
if __name__ == "__main__":
app.run(host='0.0.0.0', port=port, debug=True)
档案
web: gunicorn --bind 127.0.0.1:5000 wsgi:app
应用程序/main.py
from flask import Flask
app = Flask(__name__)
@app.route("/")
def home_view():
return "<h1>Welcome to Flask</h1>"
要求.txt
click==8.0.1
colorama==0.4.4
Flask==2.0.1
gunicorn==20.1.0
itsdangerous==2.0.1
Jinja2==3.0.1
MarkupSafe==2.0.1
Werkzeug==2.0.1
运行时.txt
python-3.9.6
解决方案
欢迎来到 Stackoverflow @vishnuvreddy
由于您正在决定使用端口
port = int(os.environ.get("PORT", 5000))
并--bind
在 Procfile 中提到如下
web: gunicorn --bind 127.0.0.1:5000 wsgi:app
互相冲突。
解决方案
将 Procfile 更改为
web: gunicorn wsgi:app
推荐阅读
- javascript - 如何等待元素出现在浏览器上,然后在 testcafe 中单击它?
- python-3.x - 无法使用预加载的 uWSGI 更便宜的算法
- javascript - 无法读取 Discord.js 上未定义的属性“startsWith”
- sql-server - VB.Net 中日期和 SQL 的数组列表
- android - 在 ConstraintLayout 中自动调整多行文本视图的大小
- google-cloud-platform - YouTube API V3 - HTTP 引荐来源网址限制
- bash - 自动在服务器之间进行 FTP 传输
- html - 无法在 React js 中检索和操作 CSS
- java - 在使用 Collections.emptyList() 声明后,延迟重新初始化列表以进行修改
- javascript - GraphQL AWS Amplify @connection 未引入连接数据