WSGI - How Does It Affect Me?
Bruno Desthuilliers
onurb at xiludom.gro
Mon Oct 9 06:44:22 EDT 2006
Sybren Stuvel wrote:
> Gregory PiƱero enlightened us with:
>> So I keep hearing more and more about this WSGI stuff, and honestly I
>> still don't understand what it is exactly
>
> AFAIK it's a standard for web frameworks.
It's not. It's a protocol for HTTP servers <-> Python web applications
interaction, and barely higher-level than CGI itself.
> In such a framework, you
> receive a 'request' object, and return a 'response' object. If I'm
> correct, the WSGI describes things like the method and property names
> on those objects etc.
It's much more simple. The "request" is a CGI-environ like dict, the
"response" is made of a callable(http_code, *http_headers) plus an
iterable for the response's body. Here's the standard wsgi hello_world:
def hello_app(environ, start_response):
start_response('200 OK', [('Content-type', 'text/plain')])
return ['Hello WSGI World']
The WSGI spec is really dead-simple. It shouldn't take much more than 10
to 15 minutes to read and understand for anyone having some basic
knowledge about HTTP and web programming.
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"
More information about the Python-list
mailing list