Running flask as package in production

You absolutely can use Gunicorn to run this project. Gunicorn is not limited to a single file, it imports Python modules just the same as flask run can. Gunicorn just needs to know the module to import, an the WSGI object to call within that module.

When you use FLASK_APP, all that flask run does is look for module.app, module.application or instances of the Flask() class. It also supports a create_app() or make_app() app factory, but you are not using such a factory.

Gunicorn won't search, if you only give it a module, it'll expect the name application to be the WSGI callable. In your case, you are using app so all you have to do is explicitly tell it what name to use:

gunicorn app:app

The part before the : is the module to import (app in your case), the part after the colon is the callable object (also named app in your module).

If you have set FLASK_APP as a Heroku config var and want to re-use that, you can reference that on the command line for gunicorn:

gunicorn $FLASK_APP:app