Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: 65b2eb9dfebe873e8ee5821f13d5a8c07d9c89c2 authored by Georg Brandl on 05 December 2010, 11:42:38 UTC
Fix title.
Tip revision: 65b2eb9
cgi2.py
#!/usr/bin/env python3

"""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