Reputation: 3327
I have a Flask application that I have deployed to Heroku, but I get an error:
2018-08-27T12:39:32.197715+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=heroku-seb-test.herokuapp.com request_id=3e02d494-1a3f-4467-9eaa-aaa551b4ca03 fwd="91.143.113.54" dyno= connect= service= status=503 bytes= protocol=https
It appears that it is a mistake in my Flask app structure, because just above it throws a Python / Flask exception:
File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/util.py", line 357, in import_app
__import__(module)
ImportError: No module named app
Here is my folder structure:
Here is my routes.py
file:
from flask import Flask
from flask import render_template, request, flash, session, url_for,
redirect
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
app.run(debug=True)
Here is my Procfile
:
web: gunicorn app:app
Upvotes: 0
Views: 1565
Reputation: 136840
The Procfile
tells Heroku how to run your application. gunicorn
expects to be given an argument in the form of module.variable
identifying the thing it should run.
Today you're telling it that your app is in a variable called app
in a module called app
:
web: gunicorn app:app
But your module isn't called app
—it's called routes
(the file is routes.py
). Update your Procfile
to point to the correct object:
web: gunicorn routes:app
Commit that change and push to Heroku to see its effect. (Or you can use heroku local
to try it out locally.)
Upvotes: 2