import RPi.GPIO as GPIO
import urllib2
# init
lamp = 40
GPIO.setmode(GPIO.BOARD)
GPIO.setup(lamp, GPIO.OUT)
while True:
# get the lamp status from the server
status = urllib2.urlopen("http://udevcommunity.org/
uconf2-iot-test/get_lamp_status.php").read()
# Turn ligh ON/OFF according to the server response
if (status == '1') # ON
GPIO.output(lamp, 1)
elif (status == '0') # OFF
GPIO.output(lamp, 0)