blob: 8026c552b214681be0c8353e8e78396aa668ece1 [file] [log] [blame]
Benjamin Peterson9cf41d02010-03-11 22:33:25 +00001#!/usr/bin/env python
Guido van Rossum68077212002-10-16 21:01:27 +00002
3"""CGI test 2 - basic use of cgi module."""
4
5import cgitb; cgitb.enable()
6
7import cgi
8
9def main():
10 form = cgi.FieldStorage()
11 print "Content-type: text/html"
12 print
13 if not form:
14 print "<h1>No Form Keys</h1>"
15 else:
16 print "<h1>Form Keys</h1>"
17 for key in form.keys():
18 value = form[key].value
19 print "<p>", cgi.escape(key), ":", cgi.escape(value)
20
21if __name__ == "__main__":
22 main()