setting environment variables in heroku for flask app

前端 未结 2 811
名媛妹妹
名媛妹妹 2020-12-30 12:48

I have a flask application that uses different configuration files for development and production environments. The relevant piece of code is this:

app.conf         


        
2条回答
  •  失恋的感觉
    2020-12-30 13:25

    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
    

提交回复
热议问题