cgi Module Example

Example of using CGI module

     #!/usr/local/bin/python
     import cgi
     form = cgi.FieldStorage()         # Read query string
     name = form["name"].value         # Get 'name' field from form
     email = form["email"].value       # Get 'email' field from form
     
     print "Content-type: text/html"
     print
     print "<H1>Hello %s. Your email is %s</h1>" % (name,email)
     

Comments

  • There is much more to this module than presented here.
  • Plus a number of security implications.
  • However, there are now better ways to do this sort of thing (PHP3, Zope, etc...)
<<< O'Reilly OSCON 2000, Advanced Python Programming, Slide 99
July 17, 2000, beazley@cs.uchicago.edu
>>>