RE: Conversion of http escape characters (Example that uses www.py)

Michael McLay (mclay@eeel.nist.gov)
Tue, 14 Jun 94 12:41:58 EDT

Just in case someone is interested, here's an example that uses
www.py. It is an enhanced version of the NCSA post-query program. It
simply echos the names/value pairs back to the client. I find it
handy for debugging WWW forms. Make sure the Python sys.path includes
the directory of the CGI scripts for the httpd server.

Michael

-----------------------------post-query.py---------------------------------
#!/usr/local/bin/python
import os
from www import *

form = FormContent()

keys = form.keys()
keys.sort()
print_header('Post test')
print_title('Post Query Test')
print '<B>The following name/value pairs were entered in the form:</B><DL>'
for i in keys:
if form.length(i) > 1:
for j in form.values(i):
print '<DD>',i, '=', j
print ''

else:
print '<DD>',i, '=', form.stripped(i)
# print '<P>'
print '</DL>'

print "<H3>The following operating system environment variables were set by the CGI script:</H3>"

t = os.environ.keys()
t.sort()
print '<DL>'
for key in t:
print "<DD>",key,"=", os.environ[key]
print '</DL>'

print """
<H3>These operating system environment variables could have been set:</H3>
<UL>
<LI>AUTH_TYPE
<LI>CONTENT_LENGTH
<LI>CONTENT_TYPE
<LI>DATE_GMT
<LI>DATE_LOCAL
<LI>DOCUMENT_NAME
<LI>DOCUMENT_ROOT
<LI>DOCUMENT_URI
<LI>GATEWAY_INTERFACE
<LI>LAST_MODIFIED
<LI>PATH
<LI>PATH_INFO
<LI>PATH_TRANSLATED
<LI>QUERY_STRING
<LI>REMOTE_ADDR
<LI>REMOTE_HOST
<LI>REMOTE_IDENT
<LI>REMOTE_USER
<LI>REQUEST_METHOD
<LI>SCRIPT_NAME
<LI>SERVER_NAME
<LI>SERVER_PORT
<LI>SERVER_PROTOCOL
<LI>SERVER_ROOT
<LI>SERVER_SOFTWARE
</UL>
"""