This is not really a Dash question, but is there an easy way to initialize global variables in the module containing the Dash app, if I run it through gunicorn?
For example, I would like to provide the password to the database when I start the application via a command line argument, and store this password in a global variable in the module.
This sort of thing is commonly done with environment variables:
In your shell or in a bash script before running the app:
Within your app:
db_password = os.getenv('DB_PASSWORD)
assert DB_PASSWORD is not None
This is not gunicorn specific, but can be used to pass arbitrary information into your app.