-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcountdown.py
More file actions
executable file
·37 lines (31 loc) · 983 Bytes
/
countdown.py
File metadata and controls
executable file
·37 lines (31 loc) · 983 Bytes
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
#!/usr/bin/python3
from bottle import route, run, static_file
from time import sleep
run_state = "run"
duration = 300
valid_states = ("run", "pause","reload")
@route('/')
def index():
# print('index requested')
return static_file('index.html', root='content')
@route('/control=<command>')
def command(command):
print('control function {} requested'.format(command))
print(command)
for com in command.split('&'):
if com.lower() in valid_states:
global run_state
run_state = com.lower()
elif com.isdigit():
global duration
duration = int(com)
@route('/<filename:re:.*\.(html|css|js)$>')
def static_file_return(filename):
# print('file {} requested'.format(filename))
return static_file(filename, root='content')
@route('/run_state')
def return_state():
global run_state, duration
response = run_state+'&'+str(duration)
return response
run (host='0.0.0.0', port=80, debug=True)