FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!

Now with publisher handler




In the previous post I set up a Python cgihandler. This post is about the publisher handler. This time you will need two files again:

The .htaccess has:
Code:
AddHandler mod_python .py
PythonHandler mod_python.publisher
PythonDebug On
Options +MultiViews
MultiviewsMatch Handlers

And the Python code has:
Code:
#!/usr/bin/env python

import re
import cgi
import cgitb; cgitb.enable()  # for troubleshooting

...

def decode(req):
    req.content_type = "text/html"
    form = req.form
...
    # Send web page
    #
    req.write(content)

The decode function parses the form arguments given (if any) and generates the HTML content for the browser. You use this code through URL "http://.../opel/vin/decode". So, it's easy to add more functionality just by adding a function definition into vin.py.

The script vin.py decodes the Opel Vehicle Identification Number. You can try it here: http://www.kta.frihost.org/opel/vin/decode.

I import cgi for cgi.escape.



0 blog comments below




FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.