Archive for December, 2004

pyhtml

December 26th, 2004 | Category: Python, Utilities

PHP-style inline code in Python.

Here’s a sample html file:

<html>
<body>
The square of 5 is
<?
print 5*5
?>
.
</body>
</html>

Note that the opening and closing tags (<? and ?>) must be in separate lines.

Installation for Apache

Add the following to your httpd.conf and copy this script into your
cgi-bin directory:

   AddHandler python-parsed-html .pyhtml
   Action python-parsed-html /cgi-bin/pyhtml.py

Also, make sure you have the actions modules (mod_actions) loaded or the above won’t work.

Download: pyhtml.py

No comments