如何在Appengine中检查Dev vs Prod?

2024-04-26 20:29:42 发布

您现在位置:Python中文网/ 问答频道 /正文

如何编写应用程序代码来检查在开发中运行的AppEngine应用程序和在生产中运行的AppEngine应用程序?你知道吗


Tags: 应用程序程序代码appengine
1条回答
网友
1楼 · 发布于 2024-04-26 20:29:42

您可以检查环境变量^{}

# 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")

相关问题 更多 >