本文介绍了如何确定您的应用程序是否在本地Python Development Server上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要以编程方式确定我的应用是否在开发中运行,以便我可以为各种常量和方法提供沙箱值。
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.
类似于:
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
推荐答案
import os
DEV = os.environ['SERVER_SOFTWARE'].startswith('Development')
这篇关于如何确定您的应用程序是否在本地Python Development Server上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!