我需要以编程方式确定我的应用程序是否在开发中运行,以便我可以为各种常量和方法提供沙盒值。
类似的东西:
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
答案 0 :(得分:36)
import os
DEV = os.environ['SERVER_SOFTWARE'].startswith('Development')