[Web-SIG] Re: Latest WSGI Draft (Phillip J. Eby)
Phillip J. Eby
pje at telecommunity.com
Tue Aug 24 17:34:55 CEST 2004
At 10:52 AM 8/24/04 -0400, Peter Hunt wrote:
>Is there a "Hello, world!" type of middleware that I could take a look at?
How about this:
def make_middleware(application):
def middleware(environ, start_response):
def extra_response(status,headers):
write = start_response(status, headers)
write('Hello world!\n')
return write
return application(environ, extra_response)
return middleware
Calling 'make_middleware(some_application)' creates a new "application"
object that can be supplied to a server, that prepends "Hello world" to the
body of every response issued by the original application object.
More information about the Web-SIG
mailing list