Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: cf60858b55a1ce8d99daa301f7aad9a7ffeb0bb7 authored by Martin v. Löwis on 28 May 2011, 11:56:22 UTC
r88824: Prepare for 2.5.6c1.
Tip revision: cf60858
cgi2.py
#!/usr/local/bin/python

"""CGI test 2 - basic use of cgi module."""

import cgitb; cgitb.enable()

import cgi

def main():
    form = cgi.FieldStorage()
    print "Content-type: text/html"
    print
    if not form:
        print "<h1>No Form Keys</h1>"
    else:
        print "<h1>Form Keys</h1>"
        for key in form.keys():
            value = form[key].value
            print "<p>", cgi.escape(key), ":", cgi.escape(value)

if __name__ == "__main__":
    main()
back to top