The WSGI standard
The
Web Server Gateway Interface (WSGI) defines a relatively simple, standardized design pattern for creating a response to a web request. The Python library's wsgiref
package includes a reference implementation of WSGI.
Each WSGI "application" has the same interface:
def some_app(environ, start_response): return content
The environ
is a dictionary that contains all of the arguments of the request in a single, uniform structure. The headers, the request method, the path, any attachments for forms or file uploads will all be in the environment. In addition to this, the OS-level context is also provided along with a few items that are part of WSGI request handling.
The start_response
is a function that must be used to send the status and headers of a response. The portion of a WSGI server that has final responsibility for building the response will use a
start_response
function to send the headers and the status as well as to build the response text. For...