The frontend routes a request whose URL is mapped to an application handler to one of many application servers. When the app server receives the request, it loads the app’s code, resource files, and configuration into a runtime environment. The server invokes the request handler for the request, gathers the response data, and sends the response data to the user.
The runtime environment includes the interpreter that executes the code (either the Python interpreter or the Java virtual machine), the application’s memory, a read-only filesystem with the application’s resource files, and APIs to the App Engine services. The runtime environment also includes the request handler API, which defines how the server and the handler communicate information about the request and the response, and how the handler emits messages to the App Engine logging system. The details differ between the Python and Java environments, but can involve environment variables and the system input and output streams.
When an app server receives a request intended for a Python application, it compares the URL path of the request to the URL patterns in in the app’s app.yaml file. Each URL pattern is associated with a file of Python code (a “script”), and the first pattern to match the path identifies the script that will handle the request.
The server uses the Common Gateway Interface (CGI) standard to communicate with the Python code. CGI is one of the earliest building ...