Some really simple cgi examples. cgi3 is a MiniWiki.

This commit is contained in:
Guido van Rossum 2002-10-16 21:01:27 +00:00
parent 60a5d72908
commit 68077210c2
4 changed files with 157 additions and 0 deletions

22
Demo/cgi/cgi2.py Executable file
View file

@ -0,0 +1,22 @@
#!/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()