首页 > 解决方案 > 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

标签: pythonflaskheroku

解决方案


欢迎来到 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

推荐阅读