I have a flask application that uses different configuration files for development and production environments. The relevant piece of code is this:
app.config.from_object('config.dev')
app.config.from_envvar('SPOTPIX_SETTINGS', silent=True)
When i'm developing in my local server, the configurations are taken from config.dev, but when i push the code to heroku, i would like to set SPOTPIX_SETTINGS environment variable to point to the 'config.prod' file. This can be done in heroku command line client like so:
heroku config:set SPOTPIX_SETTINGS=
However, I have no clue what should i write to the right of the equals sign, as i can't assign the absolute path of the production configuration file to the environment variable, because this is not the same in heroku as it is in my development machine.
Thank you very much!
You should use a env variable
to look if you are in dev or heroku.
heroku config:set IS_HEROKU=True
Then in your file
import os
is_prod = os.environ.get('IS_HEROKU', None)
if is_prod:
#here goes all your heroku config
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With