#!/usr/bin/env python
from time import sleep
import webiopi
import RPi.GPIO as GPIO

    
# Enable debug output
webiopi.setDebug()


GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)


def ModeIO( Pin , Mode):
  # only 2 possibilities
  if Mode in ["OUT"]:
    GPIO.setup(int(Pin), GPIO.OUT)
  if Mode in ["IN"]:
    GPIO.setup(int(Pin), GPIO.IN)

def SetIO( Pin, Value):
   #only 4  possibilities
   if Value in ["true","false","0","1"]:
     GPIO.output(int(Pin), Value in ["true","1"])

server = webiopi.Server(port=8000, login="webiopi", password="framboise")

server.addMacro(ModeIO)
server.addMacro(SetIO)

webiopi.runLoop()
server.stop()