Wednesday, November 23, 2011

The envrion dictionary in mod_wsgi applications

The following codes will show the content of the environ dictionary for quick debugging.
def application(environ, start_response):
    output = ['%s: %s' % (key, value) for key, value in sorted(environ.items())]
    output = '\n'.join(output)

    response_headers = [
        ('Content-Length', str(len(output))),
        ('Content-Type', 'text/plain'),
    ]
    start_response('200 OK', response_headers)
    return [output]

No comments:

Post a Comment