Web server gateway interface

from Wikipedia, the free encyclopedia

The Web Server Gateway Interface ( WSGI ) is an interface specification for the Python programming language , which defines an interface between web servers and web frameworks or web application servers in order to promote the portability of web applications on different web servers.

Details

The actual interface consists of a callable object on the application side. This receives the environment variables and a function start_responseobject ( in the example) as parameters and must return an iterable object. The environment variables are transferred as an associative array ( environin the example). The function object is used to output the HTTP headers; it is called from the server side before the return value of the function is sent to the client.

Example:

def app(environ, start_response):
    start_response('200 OK', [('content-type', 'text/plain')])
    return [b'Hello world!']

background

In the last few years, a large number of web application frameworks and web application servers have been developed based on Python . The difficulty was that choosing a framework limited the choice of web server and vice versa. This made it difficult to choose a system and made portability more difficult if you wanted to use a different framework or a different web server later. To counteract this problem, the Python Web Server Gateway Interface was created - conceived as a uniform interface ( middleware ) between the two worlds. This should enable a separation of the web server and the application behind it and thus increase the portability for them. The first draft of the associated Python Enhancement Proposal 333 was dated December 7, 2003.

application

So far, only a few websites have become known for extensive use of WSGI. WSGI is currently used primarily via mod_wsgi in Apache web servers or via uwsgi in Nginx or Cherokee servers. Both solutions can work as an independent system service (daemon) separately from the web server and thus offer not only limited security and performance advantages, but also convenient options for scaling and uninterrupted updates.

WSGI compatible software

Web links

Individual evidence

  1. mod_wsgi Usage Statistics . Retrieved August 1, 2020.
  2. w3techs.com
  3. wiki.nginx.org
  4. cherokee-project.com
  5. uwsgi Zerg fashion . Retrieved September 27, 2013.
  6. mod_wsgi Daemon Delegation . Retrieved September 27, 2013.