Web Server Gateway Interface - Specification Overview

Specification Overview

The WSGI has two sides: the "server" or "gateway" side, and the "application" or "framework" side. To process a WSGI request, the server side provides environment information and a callback function to the application side. The application processes the request, and returns HTTP headers and request body content to the server side using the callback function it was provided.

So-called WSGI middleware implements both sides of the API so that it can intermediate between a WSGI server and a WSGI application: the middleware acts as an application from some WSGI server's point of view and as a server from some WSGI application's point of view. A "middleware" component can perform such functions as:

  • Routing a request to different application objects based on the target URL, after changing the environment variables accordingly.
  • Allowing multiple applications or frameworks to run side-by-side in the same process
  • Load balancing and remote processing, by forwarding requests and responses over a network
  • Perform content postprocessing, such as applying XSLT stylesheets

Read more about this topic:  Web Server Gateway Interface