listing15-7.py 385 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env python
  2. import cgi
  3. form = cgi.FieldStorage()
  4. name = form.getvalue('name', 'world')
  5. print("""Content-type: text/html
  6. <html>
  7. <head>
  8. <title>Greeting Page</title>
  9. </head>
  10. <body>
  11. <h1>Hello, %s!</h1>
  12. <form action='simple3.cgi'>
  13. Change name <input type='text' name='name' />
  14. <input type='submit' />
  15. </form>
  16. </body>
  17. </html>
  18. """.format(name))