#!/usr/bin/env python from fcgi import WSGIServer import cgi import string, commands def test_app(environ, start_response): start_response('200 OK', [('Content-Type', 'text/html')]) yield 'Python Exploration\n' \ '\n' \ '

Environment Variables

\n' \ '' names = environ.keys() names.sort() for name in names: yield '\n' % ( name, cgi.escape(`environ[name]`)) form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ, keep_blank_values=1) if form.list: yield '' for field in form.list: yield '\n' % ( field.name, field.value) yield '
%s%s
Form data
%s%s
\n' commandString = "whoami" commandOutput = commands.getoutput(commandString) commandResults = cgi.escape(commandOutput) yield '
' \ '

User name: %s

' % (commandResults) yield '\n' WSGIServer(test_app).run()