I've recently started playing with the Pi and I've set it up as a webserver. I have created several html files which I can view by typing in the IP address of the Pi (192.168.1.80). I thought it would be good to be able to use Python to output html so the content can be more dynamic but I'm not having success in setting it up. I've been following the tutorials on http://raspberrywebserver.com/ with success until now.
I've got python installed and working (scripts running using a cron job) and the webserver is working OK with html files, but despite following this tutorial, and following potential solutions for numerous people with the same problem, I just cant seem to get it working. Tutorial is here: http://raspberrywebserver.com/cgiscript ... ython.html
So, I've got a python file (called test.py) which simply has the following code:
Code: Select all
#!/user/bin/python
import cgi
cgi.test()
In the file "default" in my Apache2 "sites-enabled" folder, I have the additional "ExecCGI" added to my options line for /var/www/ and I've added the line "AddHandler cgi-script .py".
Whenever I load the page through Google Chrome, I get an "Internal Server Error". Looking at the logs on my Pi, I get "Premaure end of script headers" and "No such file or directory: exec of '/var/www/test.py' failed" in my Apache2 error log.
I have been searching various potential solutions all day without any luck. If I remove the "ExecCGI" "AddHandler" lines mentioned above, the text of the file loads, so the file is there!
Can anyone help me with where I am going wrong?