Python chunks are in italic
1 <html> 2 <head> 3 <title>Python Inside HTML test</title> 4 <style type="text/css"> 5 th {background-color : #A0A0A0} 6 </style> 7 </head> 8 9 <body> 10 11 <h2>HTTP headers</h2> 12 13 <table border="1"> 14 <tr> 15 <th>Key</th> 16 <th>Value</th> 17 </tr> 18 <% for item in HEADERS.keys(): 19 print "<tr><td>%s</td><td>%s</td></tr>\n" % (item,HEADERS[item])%> 20 </table> 21 22 <h4>Current directory : <%= os.getcwd()%></h4> 23 24 <% def square(x): 25 return x*x%> 26 27 <% for i in range(10):%> 28 <%= i%> * <%= i%> : <b> <%= square(i)%> </b> 29 <br> 30 <% end%> 31 32 <p> 33 <h4>Namespace</h4> 34 <% print dir()%> 35 36 <h4>Available modules</h4> 37 <% 38 import types 39 for item in globals().keys(): 40 if type(globals()[item]) is types.ModuleType: 41 print item,'<br>'%> 42 43 </body> 44 45 </html> 46 47 |