sampleposteddata.py 1.9 KB

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