#! /usr/local/bin/python import cgi import urllib import string # As per CGI, our stdout is going to the HTTP client. We need to spit # out the standard MIME header stuff, and then the hardcoded part of # the HTML to return. print 'Content-type: text/html' print print '
' # A dictionary to map short keys to longer names. The keys are passed # to this script via the QUERY_STRING environment variable as defined # by CGI. The URL sent by the applet looks something like: # # http://...../cgi-bin/echovalid.py?org=NameOfOrg+age=33+name=JohnDoe # # urllib module takes care of quoting these fields on the client side, # and unquoting the fields on our side. longnames = { 'org': 'Organization', 'age': 'Age', 'name': 'Name' } # grab stuff out of QUERY_STRING and do the top level split query_string = cgi.environ['QUERY_STRING'] querylist = string.splitfields(query_string, '+') querylist.reverse() # cycle through the individual key/value pairs for f in querylist: key, value = tuple(string.splitfields(f, '=')) if value: value = urllib.unquote(value) print '%s: %s' % (longnames[key], value) # print standard HTML trailer print '' print '