如何确定您的应用是否在本地Python Development Server上运行?

时间:2011-05-06 17:14:34

标签: python google-app-engine

我需要以编程方式确定我的应用程序是否在开发中运行,以便我可以为各种常量和方法提供沙盒值。

类似的东西:

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 个答案:

答案 0 :(得分:36)

import os

DEV = os.environ['SERVER_SOFTWARE'].startswith('Development')