简体   繁体   English

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

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

I am trying to deploy my first flask application in heroku.我正在尝试在 heroku 中部署我的第一个 Flask 应用程序。 Followed steps exactly as mentioned in heroku documentation.完全按照heroku文档中提到的步骤进行操作。 But It is throwing Application error as shown below但它正在抛出应用程序错误,如下所示

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

Project Structure项目结构

app
    main.py
Pipfile
Pipfile.lock
Procfile
requirements.txt
runtime.txt
wsgi.py

wsgi.py file 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应用程序/main.py

from flask import Flask

app = Flask(__name__)

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

requirements.txt要求.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运行时.txt

python-3.9.6

Welcome to Stackoverflow @vishnuvreddy欢迎来到 Stackoverflow @vishnuvreddy

Since you are deciding port using由于您决定使用端口

port = int(os.environ.get("PORT", 5000))

and mentioned --bind in Procfile as below并在 Procfile 中提到--bind如下

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

conflict each other.互相冲突。

Solution解决方案

Change Procfile to将 Procfile 更改为

web: gunicorn wsgi:app

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM