Chris
Chris

Reputation: 171

Python: Running Flask with gunicorn produces error "Failed to find application object"

I have a pretty big Flask project I'm trying to run with gunicorn, supervisor and nginx. I am using lots of Blueprints and have one file called run.py that starts the whole application. It looks like this:

from webapp import app, socketio
if __name__ == "__main__":
    socketio.run(app)

webapp ist the main module that contains all the views, models and template files.

When I try to bind gunicorn gunicorn --bind 127.0.0.1:8000 run & it produces the following error: Failed to find application object 'application' in 'run'. I have no idea how to fix this problem.

I am trying to follow this tutorial.

Upvotes: 0

Views: 890

Answers (1)

J.J. Hakala
J.J. Hakala

Reputation: 6214

In the tutorial mentioned gunicorn is started by

gunicorn app:app -b localhost:8000

i.e. there is that :app part that is not in

gunicorn --bind 127.0.0.1:8000 run

which should probably be

gunicorn --bind 127.0.0.1:8000 run:app

Upvotes: 1

Related Questions