Parent: [468a2b] (diff)

Download this file

switcherapp.py    52 lines (39 with data), 1.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/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()