Code: Select all
#!/usr/bin/env python
import cgi
import cgitb; cgitb.enable()
import RPi.GPIO as GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.OUT)
GPIO.output(11, False)
print "Content-type: text/html"
print
print """
<html>
<head><title>light goes on</title></head>
<body>
<h3> light is on</h3>
</body>
</html>
"""
<class 'RPi.GPIO.SetupException'> Python 2.7.3: /usr/bin/python
Fri Feb 15 20:58:41 2013
A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.
/usr/lib/cgi-bin/test.py in ()
4 import cgitb; cgitb.enable() # for troubleshooting
5
=> 6 import RPi.GPIO as GPIO
7 GPIO.setwarnings(False)
8 GPIO.setmode(GPIO.BOARD)
RPi undefined, GPIO undefined
<class 'RPi.GPIO.SetupException'>: No access to /dev/mem. Try running as root!
args = ('No access to /dev/mem. Try running as root!',)
message = 'No access to /dev/mem. Try running as root!'
Is there any way the www-data user can have access to this resource or is there another way for this to work? I am a beginner at all this so please keep the replies simple!
Any help would be great.
Many thanks