How can I detect Heroku's environment?

前端 未结 7 1662
Happy的楠姐
Happy的楠姐 2020-12-24 05:40

I have a Django webapp, and I\'d like to check if it\'s running on the Heroku stack (for conditional enabling of debugging, etc.) Is there any simple way to do this? An envi

7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-24 06:15

    An ENV var seems to the most obvious way of doing this. Either look for an ENV var that you know exists, or set your own:

    on_heroku = False
    if 'YOUR_ENV_VAR' in os.environ:
      on_heroku = True
    

    more at: http://devcenter.heroku.com/articles/config-vars

提交回复
热议问题