PYTHON   60

sample posted data

Guest on 25th June 2022 08:07:34 AM

  1. #!/usr/bin/env python
  2.  
  3. """
  4. FCKeditor - The text editor for Internet - http://www.fckeditor.net
  5. Copyright (C) 2003-2010 Frederico Caldeira Knabben
  6.  
  7. == BEGIN LICENSE ==
  8.  
  9. Licensed under the terms of any of the following licenses at your
  10. choice:
  11.  
  12. - GNU General Public License Version 2 or later (the "GPL")
  13.   http://www.gnu.org/licenses/gpl.html
  14.  
  15. - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
  16.   http://www.gnu.org/licenses/lgpl.html
  17.  
  18. - Mozilla Public License Version 1.1 or later (the "MPL")
  19.   http://www.mozilla.org/MPL/MPL-1.1.html
  20.  
  21. == END LICENSE ==
  22.  
  23. This page lists the data posted by a form.
  24. """
  25.  
  26. import cgi
  27. import os
  28.  
  29. # Tell the browser to render html
  30. print "Content-Type: text/html"
  31. print ""
  32.  
  33. try:
  34.         # Create a cgi object
  35.         form = cgi.FieldStorage()
  36. except Exception, e:
  37.         print e
  38.  
  39. # Document header
  40. print """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  41. <html>
  42.         <head>
  43.                 <title>FCKeditor - Samples - Posted Data</title>
  44.                 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  45.                 <meta name="robots" content="noindex, nofollow">
  46.                 <link href="../sample.css" rel="stylesheet" type="text/css" />
  47.         </head>
  48.         <body>
  49. """
  50.  
  51. # This is the real work
  52. print """
  53.                 <h1>FCKeditor - Samples - Posted Data</h1>
  54.                 This page lists all data posted by the form.
  55.                 <hr>
  56.                 <table border="1" cellspacing="0" id="outputSample">
  57.                         <colgroup><col width="80"><col></colgroup>
  58.                         <thead>
  59.                                 <tr>
  60.                                         <th>Field Name</th>
  61.                                         <th>Value</th>
  62.                                 </tr>
  63.                         </thead>
  64. """
  65. for key in form.keys():
  66.         try:
  67.                 value = form[key].value
  68.                 print """
  69.                                 <tr>
  70.                                         <th>%s</th>
  71.                                         <td><pre>%s</pre></td>
  72.                                 </tr>
  73.                         """ % (cgi.escape(key), cgi.escape(value))
  74.         except Exception, e:
  75.                 print e
  76. print "</table>"
  77.  
  78. # For testing your environments
  79. #print "<hr>"
  80. #for key in os.environ.keys():
  81. #       print "%s: %s<br>" % (key, os.environ.get(key, ""))
  82. #print "<hr>"
  83.  
  84. # Document footer
  85. print """
  86.         </body>
  87. </html>
  88. """

Raw Paste


Login or Register to edit or fork this paste. It's free.