-1

Trying to follow best practices for a Flask app running in Heroku so I'm moving things from app.py to working with blueprints.

The current directory structure is as follows:

--root
  --application
    --admin_blueprint
    --another_blueprint
    --wsgi.py (app = create_app())
    --__init__.py (this has def create_app, which handles creating my app)
  --migration
  --Procfile
  --requirements.txt
  --runtime.txt
  --config.py
  --manage.py

This is init.py

from flask import Flask

...

def create_app():
    app = Flask(...)
...
    return app

and this is wsgi.py

from application import create_app

app = create_app()

if __name__ == '__main__':
    app.run(host='0.0.0.0')

I cannot for the life of me figure out how to do the Procfile correctly, this is what I previously had when I had app.py and wsgi.py in my root directory and it was working fine on Heroku:

web: gunicorn app:wsgi

I've tried some of these:

web: gunicorn application:wsgi
web: gunicorn application.wsgi
web: gunicorn --pythonpath application application:wsgi
web: gunicorn application.wsgi.py
web: gunicorn "application.wsgi.py"
web: gunicorn "application/wsgi.py"

flask run works because I've exported FLASK_APP=application.wsgi.py

Thank you.

iklinac
  • 14,944
  • 4
  • 28
  • 30
efecarranza
  • 744
  • 2
  • 7
  • 16

1 Answers1

-1

Use application.wsgi:app

application.wsgi (the part before the colon) instructs gunicorn how to resolve the module.

and app (the part after the colon) gives the name of the WSGI application declared in the resolved module.

:app can be omitted and gunicorn defaults to looking in the module for a WSGI application with the name application.

Oluwafemi Sule
  • 36,144
  • 1
  • 56
  • 81