On Mon, Jun 14, 2010 at 12:54 PM, Ben Timby <[email protected]> wrote:
> Like this:

That simple test often works, but it could be improved.

def show_environ(environ, start_response):
    import os
    lines = []

    lines.append("OS environment:")
    for name, value in sorted( os.environ.items() ):
        lines.append( "   %s = %r" % (name, value) )

    lines.append("")
    lines.append("WSGI environment:")
    for name, value in sorted( environ.items() ):
        lines.append( "   %s = %r" % (name, value) )

    start_response( "200 OK", [ ("Content-Type", "text/plain"),
("Cache-Control", "no-cache")  ] )
    return [ '"\n".join(lines) ]

application = show_environ


By using text/plain you avoid problems with escaping HTML, as
well as HTML visually eating whitespace.  Using the %r for the value
lets you see any non-printables, as well as unicode values
(if any).

-- 
Deron Meranda
http://deron.meranda.us/

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en.

Reply via email to