STATIC_FILES='/home/pi/paco/PacoServer/static'
SERIAL_PORT='/dev/ttyUSB0'

from paco import Paco
from bottle import route, run
from bottle import static_file
from bottle import template

paco = None

@route('/')
def homepage():
    return template('index') 

@route('/css/<filename:path>')
def css(filename):
    return static_file(filename, root='%s/css' % STATIC_FILES)

@route('/fonts/<filename:path>')
def fonts(filename):
    return static_file(filename, root='%s/fonts' % STATIC_FILES)

@route('/img/<filename:path>')
def img(filename):
    return static_file(filename, root='%s/img' % STATIC_FILES)

@route('/js/<filename:path>')
def js(filename):
    return static_file(filename, root='%s/js' % STATIC_FILES)

@route('/less/<filename:path>')
def less(filename):
    return static_file(filename, root='%s/less' % STATIC_FILES)



@route('/panLeft')
def panLeft():
    if paco.pan_angle > 0:
       paco.pan_angle = paco.pan_angle - 5
       paco.pan(paco.pan_angle)

@route('/panRight')
def panRight():
    if paco.pan_angle < 185:
       paco.pan_angle = paco.pan_angle + 5 
       paco.pan(paco.pan_angle)

@route('/tiltDown')
def tiltDown():
   if paco.tilt_angle > 0:
       paco.tilt_angle = paco.tilt_angle - 5
       paco.tilt(paco.tilt_angle)

@route('/tiltUp')
def tiltUp(): 
   if paco.tilt_angle < 90:
       paco.tilt_angle = paco.tilt_angle + 5
       paco.tilt(paco.tilt_angle)

if __name__ == "__main__":

    paco = Paco(SERIAL_PORT)

    paco.tilt_angle = 50
    paco.pan_angle = 90


    run(host='0.0.0.0', port='9000', debug=True)


