Staging
v0.5.1
swh:1:snp:635f4099902912592851108bcac178ff574f7c5f
Raw File
Tip revision: 1563f164e52d886d7f5ee7019bf176c8514b0243 authored by Benjamin Peterson on 11 June 2016, 21:46:26 UTC
2.7.12 release candidate 1
Tip revision: 1563f16
cgi2.py
#!/usr/bin/env 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