Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setting environment variables in heroku for flask app

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!

like image 688
stensootla Avatar asked Feb 04 '15 14:02

stensootla


1 Answers

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
like image 117
levi Avatar answered Sep 20 '22 13:09

levi