Web Server Gateway Interface: Difference between revisions

Content deleted Content added
m Idea: commification
No edit summary
Line 1:
'''Anglers Reach''' is a village on the shores of [[Lake Eucumbene]] near [[Adaminaby]]. It has a resident population of about 40, but is popular as a holiday destination for trout fishing and as a base for visitors to the skifields at [[Mount Selwyn]].
{{comp-stub}}
 
The '''Web Server Gateway Interface''' defines a simple and universal interface between web servers and web applications or frameworks for the [[Python programming language]].
 
{{NewSouthWales-geo-stub}}
==Idea==
Python boasts a wide variety of web application frameworks. This can be a problem for new Python users because, generally speaking, their choice of web framework will limit their choice of usable web servers, and vice versa.
 
WSGI proposes a simple and universal interface between web servers and web applications or frameworks.
 
==Specification Overview==
The WSGI interface has two sides: the "server" or "gateway" side, and the "application" or "framework" side. The server side invokes a callable object that is provided by the application side. Additionally WSGI provides middlewares, components that play both sides.
 
A "middleware" component can perform such functions as:
* Routing a request to different application objects based on the target URL, after rewriting the environ 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 XSL stylesheets
 
==Example Application==
A WSGI compatible "[[Hello World]]" application:
<pre>
def app(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return ['Hello World\n']
</pre>
 
==WSGI compatible Applications and Frameworks==
There are numerous [[Web application framework]]s supporting WSGI:
* [[Django web framework|Django]]
* [[TurboGears]]
* [[Pylons web framework|Pylons]]
 
Additionally there are two simple publishers:
* [http://www.saddi.com/software/flup/ flup]
* [http://wsgiarea.pocoo.org/colubrid/ Colubrid]
 
==Wrappers==
The server or gateway invokes the application callable once for each request it receives from an HTTP client, that is directed at the application.
 
Currently wrappers are available for [[FastCGI]], [[CGI]], [[SCGI]], [[AJP]] using the flup package.
 
 
==External links==
* [http://www.python.org/peps/pep-0333.html PEP 333] defining the interface standard
* http://www.pythonpaste.org/ - WSGI metaframework
* http://www.saddi.com/software/flup/ - Flup Publisher and Request Handlers