Skip to content

Instantly share code, notes, and snippets.

@Voronenko
Created October 6, 2015 20:24
Show Gist options
  • Save Voronenko/b018bc2322fa39cc588f to your computer and use it in GitHub Desktop.
Save Voronenko/b018bc2322fa39cc588f to your computer and use it in GitHub Desktop.
Sample wsgi to test apache + mod_wsgi setup
import cStringIO
import os
def application(environ, start_response):
headers = []
headers.append(('Content-Type', 'text/plain'))
write = start_response('200 OK', headers)
input = environ['wsgi.input']
output = cStringIO.StringIO()
print >> output, "PID: %s" % os.getpid()
print >> output, "UID: %s" % os.getuid()
print >> output, "GID: %s" % os.getgid()
print >> output
keys = environ.keys()
keys.sort()
for key in keys:
print >> output, '%s: %s' % (key, repr(environ[key]))
print >> output
output.write(input.read(int(environ.get('CONTENT_LENGTH', '0'))))
return [output.getvalue()]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment