def application(environ, start_response):
import cgi
write_fn = start_response('200 OK', [('Content-Type', 'text/html')])
yield '
os.environment\n' \
'\n' \
'os.environment
\n' \
''
names = environ.keys()
names.sort()
for name in names:
yield '%s | %s |
\n' % (
name, cgi.escape(`environ[name]`))
form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ,
keep_blank_values=1)
if form.list:
yield 'Form data |
'
for field in form.list:
yield '%s | %s |
\n' % (
field.name, field.value)
write_fn('This has been write()n | :-) |
\n');
yield '
\n' \
'\n'
from wsgiref.handlers import CGIHandler
CGIHandler().run(application)