15.2 The WSGI standard
The Web Server Gateway Interface (WSGI) defines a standard interface for creating a response to a web request. This is a common framework for most Python-based web servers. A great deal of information is present at the following link: http://wsgi.readthedocs.org/en/latest/.
Some important background on WSGI can be found at https://www.python.org/dev/peps/pep-0333/.
The Python library’s wsgiref
package includes a reference implementation of WSGI. Each WSGI application has the same interface, as shown here:
def some_app(environ, start_response):
# compute the status, headers, and content of the response
start_response(status, headers)
return content
The environ
parameter is a dictionary that contains all of the arguments of the request in a single, uniform structure. The headers, the request method, the path, and any attachments for forms or file uploads will all...