The Backend API is deprecated as of March 13, 2014. Although Google will
continue to support the Backend API in accordance with our
terms of service
, it is strongly recommended that all new applications
use the
Modules API
instead.
This Backends API allows you to retrieve information about the backend handling the current request, and compute the URL and hostname of any other backend or backend instance within the same application. The methods in this API work in both production and the development server .
The
google.appengine.api.backends
package provides the following functions:
- get_backend ()
-
Gets the name (
BACKEND_ID
) of the backend handling the current request. ReturnsNone
if the request is not handled by a backend. - get_hostname ( backend = None , instance = None )
-
Returns the hostname of the backend or backend instance.
- backend = None
-
The optional backend name, a string. You can identify the name of a backend handling a request using
get_backend()
. Specifying
backend=None
returns the current backend; this is the default behavior. - instance = None
- The optional backend instance id, an integer. You can identify the instance id using get_instance() . If provided, the hostname represents the specific instance. If absent, the hostname represents the backend as a whole. Raises the InvalidInstanceError if the instance id is not an integer.
- get_instance ()
-
Gets the id (
INSTANCE_ID
) for the instance handling the current request. Returns the instance ID (numbering starts at0
), orNone
if the request is not handled by a backend. - get_url ( backend = None , instance = None , protocol = 'HTTP' )
-
Gets the address of a specific backend. Returns a local address if run in the development server, or a production address if run in production. Returns the HTTP or HTTPS address of a specific backend.
Arguments
- backend = None
-
The optional backend name. You can identify the name of a backend handling a request using
get_backend()
. Specifying
backend=None
returns the current backend; this is the default behavior. - instance = None
- The optional backend instance id, an integer. If provided, the URL targets the specific instance. If absent, the URL points to a load-balancing hostname for the backend. You can identify the instance id using get_instance() . Raises the InvalidInstanceError if the instance id is not an integer.
- protocol = 'http'
-
The protocol to use, either
HTTP
(default) orHTTPS
. The development server supports onlyHTTP
. Production supports bothHTTP
andHTTPS
. Raises the InvalidBackendError if the provided backend cannot be found.