-
Notifications
You must be signed in to change notification settings - Fork 11
/
server.py
57 lines (40 loc) · 1.27 KB
/
server.py
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
52
53
54
55
56
57
import SocketServer
import BaseHTTPServer
from string import Template
val = {
"cur": "start",
"curLabel": "STARTED",
"next": "stop",
"nextLabel": "STOP",
"curVideo": "vSTAGE",
"curVideoAgo": "30 sec",
"curAudio": "[aPLVOX, aWLINST, aDRUMS, aBASS]",
"danteRmsAgo": "30 sec",
"danteRebootAgo": "5 hrs",
"debugLog": "00:00:00 Meow debug text",
}
with open("template.html") as f:
status_templ = Template(f.read())
print status_templ
class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(self):
if "stop=STOP" in self.path:
print "ZOMG STOP!"
self.send_response(302)
self.send_header("Location", "/")
self.end_headers()
return
if "start=START" in self.path:
print "ZOMG START!"
self.send_response(302)
self.send_header("Location", "/")
self.end_headers()
return
# always dump current status
self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()
self.wfile.write(status_templ.substitute(val))
SocketServer.TCPServer.allow_reuse_address = True
server = SocketServer.TCPServer(("",8080), MyHandler)
server.serve_forever()