#!/usr/bin/python2 import cgi def main(): form = cgi.FieldStorage() # lines above are totally standard print "Raw CGI Data" # start html with a title if form: print "Raw CGI Data:

" #
forces a newline in html for key in form: val = form.getlist(key) # returns values for key as a list if len(val) == 1: # generally there is just one value per key val = val[0] # if so I choose to display it without the list print "%s: %s
" % (key, val) # show single value or list else: print "No CGI data received" print "" # ending what the first print statement above started # this is the immediately executed code below - copy it exactly try: ## print "Content-Type: text/plain\n\n" # to see the raw text generated print "Content-type: text/html\n\n" main() except: cgi.print_exception()