Where in flask/gunicorn to initialize application
You can still use the same main() method paradigm. See this starter code below:
app = Flask(your_app_name) # Needs defining at file global scope for thread-local sharingdef setup_app(app): # All your initialization codesetup_app(app)if __name__ == '__main__': app.run(host=my_dev_host, port=my_dev_port, etc='...')
The before_first_request
method could also handle all of those items. But you'll have the delay of setup on first request rather than on server launch.