[Tutor] cgi scripts

Jim Morcombe jmorcombe at westnet.com.au
Sat Nov 8 08:22:59 CET 2008


I want to print a list of the keys and their values passed to a cgi 
script by an HTML form.
I have tried this, but just seems to crash.

Any ideas?

Jim Morcombe


#!C:\python25\python.exe

import cgi, sys
# import cgitb; cgitb.enable()

#Send errors to browser
sys.stderr = sys.stdout

#Parse data from form
data = cgi.FieldStorage()

#Send response to browser
print "Content-type: text/html\n"
print "<title>CGI Form Response</title>\n"
print "<h2>This is the data passed to the cgi script</h2><P>"

print "These are the keys\n"
print "<br>"
print for k in data.keys():
    print "key: ", k, "  value: ",  data[k]
   




More information about the Tutor mailing list