Web programming
Python
Python can be used embedded in apache like php, but with % tags.
installation
There are two different methods, mod_python.psp (python server pages) that use a php like construct. And using your own handler.
psp
Very terse !!
| install | |
|---|---|
Add the top so it will look something like :
| /etc/apache2/sites-enabled/default | |
|---|---|
| restart | |
|---|---|
testing
Now tryout a file in your document root like :
| hello | |
|---|---|
writing the handler
Add a section like this to /etc/apache2/sites-enabled/default. Or another appropriate location.
| /etc/apache2/sites-enabled/default | |
|---|---|
This means for all scripts with the .py extension under /var/www/report (absolute path) use mod_python. And in particular run the watch.py script. : from mod_python import apache def handler(req): req.content_type = "text/plain" req.write("Hello World!") return apache.OK Actually now any url you end in .py will work, http://localhost/report/watch.py but also /blerk.py even if it does not exits.