English | Site Directory

The Environment

The execution environment includes several environment variables useful to the application. Some of these are special to App Engine, while others are part of the CGI standard. Python code can access these variables using the os.environ dictionary.

The following environment variables are specific to App Engine:

  • APPLICATION_ID: The ID of the currently running application.
  • CURRENT_VERSION_ID: The major and minor version of the currently running application, as "X.Y". The major version number ("X") is specified in the app's app.yaml file. The minor version number ("Y") is set automatically when each version of the app is uploaded to App Engine. On the development web server, the minor version is always "1".
  • AUTH_DOMAIN: The domain used for authenticating users with the Users API. Apps hosted on appspot.com have an AUTH_DOMAIN of gmail.com, and accept any Google account. Apps hosted on a custom domain using Google Apps have an AUTH_DOMAIN equal to the custom domain.

The following environment variables are part of the CGI standard, with special behavior in App Engine:

  • SERVER_SOFTWARE: In the development web server, this value is "Development/X.Y" where "X.Y" is the version of the runtime.

Additional environment variables are set according to the CGI standard. For more information on these variables, see the CGI standard.

Tip: The following webapp request handler displays every environment variable visible to the application in the browser:

from google.appengine.ext import webapp
import os

class PrintEnvironmentHandler(webapp.RequestHandler):
  def get(self):
    for name in os.environ.keys():
      self.response.out.write("%s = %s<br />\n" % (name, os.environ[name]))