River's Edge Rest.& Party House Website is a community education project
[tues-crep.git] / sites / rochesterbanquets.com / httpdocs / rer-jan16 / test / python / test.py
blob846e4f37707c0e463c538ffe51f5d96a580824f8
1 import sys
2 import os
3 import re
5 def print_environ(environ=os.environ):
6 """Dump the shell environment as HTML."""
7 keys = environ.keys()
8 keys.sort()
9 i = 0
10 for key in keys:
11 if not re.search("^HTTP_|^REQUEST_", key):
12 continue
13 if i == 0:
14 print """<tr class="normal"><td>""", escape(key), "</td><td>", escape(environ[key]), "</td></tr>"
15 i = 1
16 else:
17 print """<tr class="alt"><td>""", escape(key), "</td><td>", escape(environ[key]), "</td></tr>"
18 i = 0
20 def escape(s, quote=None):
21 """Replace special characters '&', '<' and '>' by SGML entities."""
22 s = s.replace("&", "&amp;") # Must be done first!
23 s = s.replace("<", "&lt;")
24 s = s.replace(">", "&gt;")
25 if quote:
26 s = s.replace('"', "&quot;")
27 return s
30 print """Content-type: text/html
32 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
33 <html>
34 <head>
35 <title></title>
36 <link rel="stylesheet" type="text/css" href="../../css/style.css">
37 </head>
38 <body>
39 <table cellspacing="0" cellpadding="0" border="0">
40 <tr class="subhead" align="Left"><th>Name</th><th>Value</th></tr>"""
41 print_environ()
42 print """</table>
43 </body>
44 </html>"""