#!/usr/bin/python
import cgi, cgitb, os, sys
cgitb.enable(); # formats errors in HTML

sys.stderr = sys.stdout
print "Content-type: text/html"
print
print """<html>
<head><title>Show fields from CGI query string</title></head>
<body>"""

query = os.environ.get('QUERY_STRING')
if query: print "<p>QUERY_STRING:&nbsp&nbsp; <tt><font color=#FF00FF>", cgi.escape(query), "</font></tt>"

print """<p><table border>
<tr><th>Name<th>Value"""

form = cgi.FieldStorage()

for field in form.keys():
    print "<tr><td>%s<td>%s" % (field, form[field].value)

print "</table>"
print "</body></html>"
