Heroku 在部署 python Flask 网络应用程序时得到 at=error code=H10

Heroku getting at=error code=H10 while deploying python Flask web app

我正在尝试在 heroku 中部署我的第一个 flask 应用程序。完全按照 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)

Procfile

web: gunicorn --bind 127.0.0.1:5000 wsgi:app

app/main.py

from flask import Flask

app = Flask(__name__)

@app.route("/")
def home_view():
        return "<h1>Welcome to Flask</h1>"

requirements.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

runtime.txt

python-3.9.6

欢迎来到 Whosebug @vishnuvreddy

因为您正在使用

决定端口
port = int(os.environ.get("PORT", 5000))

并在 Procfile 中提到 --bind 如下

web: gunicorn --bind 127.0.0.1:5000 wsgi:app

互相冲突

解决方案

将 Procfile 更改为

web: gunicorn wsgi:app