Writing web pages in python without any environment isn’t painless. Despite inconveniences you have access to Session, Cookies and Transactions fields.
You can distinguish between incoming addresses thanks to:
request.uri field.
Simple page using just one function:
from mod_python import apache def handler ( request ): request.content_type = 'text/html' request.write ( "<html>" ) request.write ( "<head>" ) request.write ( "<title>Text Document</title>" ) request.write ( "</head>" ) request.write ( "<body bgcolor='#D2D2D2'>" ) request.write ( "<table align='center' bgcolor='#000000' cellspacing='1px' cellpadding='5px' width='60%'>" ) request.write ( "<tr><td bgcolor='#FFFFFF' align='center'>" ) request.write ( "SIMPLE WEB PAGE IN MOD_PYTHON" ) request.write ( "Res: " + str(increment(1))) request.write ( "</td></tr>" ) request.write ( "</table>" ) request.write ( "</body>" ) request.write ( "</html>" ) return apache.OK def increment(x): return x+1 |
There’s a good manual concerning mod_python here:
http://modpython.org/live/current/modpython.pdf
No comments:
Post a Comment
If you like this post, please leave a comment :)