I am trying to deploy my first flask application in heroku. Followed steps exactly as mentioned in heroku documentation. But It is throwing Application error as shown below
JavaScript
x
2
1
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
2
Project Structure
JavaScript
1
9
1
app
2
main.py
3
Pipfile
4
Pipfile.lock
5
Procfile
6
requirements.txt
7
runtime.txt
8
wsgi.py
9
wsgi.py file
JavaScript
1
7
1
from app.main import app
2
import os
3
4
port = int(os.environ.get("PORT", 5000))
5
if __name__ == "__main__":
6
app.run(host='0.0.0.0', port=port, debug=True)
7
Procfile
JavaScript
1
2
1
web: gunicorn --bind 127.0.0.1:5000 wsgi:app
2
app/main.py
JavaScript
1
8
1
from flask import Flask
2
3
app = Flask(__name__)
4
5
@app.route("/")
6
def home_view():
7
return "<h1>Welcome to Flask</h1>"
8
requirements.txt
JavaScript
1
9
1
click==8.0.1
2
colorama==0.4.4
3
Flask==2.0.1
4
gunicorn==20.1.0
5
itsdangerous==2.0.1
6
Jinja2==3.0.1
7
MarkupSafe==2.0.1
8
Werkzeug==2.0.1
9
runtime.txt
JavaScript
1
2
1
python-3.9.6
2
Advertisement
Answer
Welcome to Stackoverflow @vishnuvreddy
Since you are deciding port using
JavaScript
1
2
1
port = int(os.environ.get("PORT", 5000))
2
and mentioned --bind
in Procfile as below
JavaScript
1
2
1
web: gunicorn --bind 127.0.0.1:5000 wsgi:app
2
conflict each other.
Solution
Change Procfile to
JavaScript
1
2
1
web: gunicorn wsgi:app
2