如何检查Appengine中的Dev vs Prod?

时间:2017-05-09 23:19:32

标签: python google-app-engine google-cloud-platform

如何编写应用程序代码以检查在开发中运行的AppEngine应用程序与在Production中运行的应用程序之间的对比?

1 个答案:

答案 0 :(得分:1)

您可以查看环境变量SERVER_SOFTWARE

# Check for appengine app identity.
app_env = os.getenv('SERVER_SOFTWARE', None)
if app_env:
    if app_env.startswith('Google App Engine/'):
        # Appengine Production
        print("Appengine Production Detected")

if app_env.startswith("Development") or app_env.startswith("AppScaleServer"):
    # Dev or appscale env
    print("Local Dev / appscale detected")
else:
    print("app_env not declared")