#!/usr/bin/env python
from __future__ import print_function
#############################################################
# Note that this only works when running under specific conditions,
# e.g. with the bottle default server: module is loaded once, and
# always runs in the same interpreter
import os
import glob
import sys
import urllib
import bottle
import swgpio
# Return first value in list which is not in 'invalid'
# list. E.g. first non-None. Typ. usage is for returning dflt value if
# query result as first element is None
def choose(lst, invalid=[None]):
for value in lst:
if value not in invalid:
return value
def debug(x):
print("%s" % x, file = sys.stderr)
@bottle.route('/static/:path#.+#')
def server_static(path):
return bottle.static_file(path, root='./static')
@bottle.route('/')
def main():
return
@bottle.route('/spka')
def spkb():
swgpio.spkoff()
@bottle.route('/spkb')
def spkb():
swgpio.spkon()
@bottle.route('/linea')
def lineb():
swgpio.lineoff()
@bottle.route('/lineb')
def lineb():
swgpio.lineon()