September 2002
Intermediate to advanced
544 pages
13h 6m
English
Now let’s look at an example written in Python. If the user’s form input contains the hidden field action, the script processes that information. Otherwise, it prints a new form to be filled out. The source code for the script is in Listing 11.4.
1: #!/usr/local/bin/python 2: 3: import cgi 4: form = cgi.FieldStorage() 5: 6: def print_page_start(): 7: print "Content-type: text/html\n\n" 8: print "<html><head><title>Example Form</title></head><body>\n" 9: print "<h1>Example Form</h1>" 10: 11: def print_page_end(): 12: print "</body></html>\n" 13: 14: def print_form(): 15: print "<form>\n" 16: print "<input type=\"hidden\" name=\"action\" value=\"process\" />\n" 17: print "Name: <input ... |
Read now
Unlock full access