by forwarding requests and responses over a network Performing content post-processing, such as applying XSLT stylesheets Examples Example application A WSGI-compatible "Hello, World!" application written in Python: def application(environ, start_response): start_response('200 OK', [('Content-Type', 'text/plain')]) yield b'Hello, World!\n' Where: Line 1 defines a function named application, which takes two parameters, environ and start_response. environ is a dictionary containing CGI environment variables as well as other request parameters and metadata under well-defined keys. start_response is a callable itself, taking two positional parameters, status and response_headers. Line 2 calls start_response, specifying "200 OK" as the HTTP status and a "Content-Type" response header. Line 3 makes the function into a generator. The body of the response is returned as an iterable of byte strings. Example of calling an application A full example of a WSGI network server is outside the scope of this article. Below is a sketch of how one would call a WSGI application and retrieve its HTTP status line, response headers, and response body, as Python objects. Details of how to construct the environ dict have been omitted. from io import BytesIO def call_application(app, environ): status = None headers = None body = BytesIO() def start_response(rstatus, rheaders): nonlocal status, headers status, headers = rstatus, rheaders app_iter = app(environ, start_response) try: for data in app_iter: assert status is not None and headers is not None, \ "start_response() was not called" body.write(data) finally: if hasattr(app_iter, 'close'): app_iter.close() return status, headers, body.getvalue() environ = {...} # "environ" dict status, headers, body = call_application(app, environ) WSGI-compatible applications and frameworks Numerous web frameworks support WSGI: bjoern BlueBream bobo Bottle CherryPy Django Eventlet FastWSGI Flask Falcon (web framework) Gevent-FastCGI Google App Engine's webapp2 Gunicorn prestans mod_wsgi for use with Apache netius pycnic Paste component WebOb is specifically a WSGI extension. It was adopted by the Pylons project. Pylons Pyramid restlite Tornado Trac TurboGears Uliweb uWSGI Waitress web.py web2py weblayer Werkzeug Radicale Currently wrappers are available for FastCGI, CGI, SCGI, AJP (using flup), twisted.web, Apache (using mod_wsgi or mod_python), Nginx (using ngx_http_uwsgi_module), and Microsoft IIS (using WFastCGI, isapi-wsgi, PyISAPIe, or an ASP gateway). See also Asynchronous Server Gateway Interface (ASGI) – The spiritual successor to WSGI, adding support for asynchronous applications Rack – Ruby web server interface PSGI – Perl Web Server Gateway Interface SCGI – Simple Common Gateway Interface JSGI – JavaScript web server gateway interface References External links PEP 333 – Python Web Server Gateway Interface