How to determine if your app is running on local P

2019-03-25 03:22发布

I need to programatically determine if my app is running in development or not, so that I can provide sandbox values for a variety of constants and methods.

Something like:

if app.development: # Live mode
  FREEBASE_USER = "spam123"
  FREEBASE_PSWD = "eggs123"
  FREEBASE = freebase

else: # Sandbox mode
  FREEBASE_USER = "spam"
  FREEBASE_PSWD = "eggs"
  FREEBASE = freebase.sandbox

1条回答
贼婆χ
2楼-- · 2019-03-25 03:55
import os

DEV = os.environ['SERVER_SOFTWARE'].startswith('Development')
查看更多
登录 后发表回答