Commit 961c6df66a8e4bf209951ca38732d4e49704af3e

Authored by mik
1 parent 7b4659772f
Exists in master

add redirect to open/close in wiki

Showing 1 changed file with 9 additions and 0 deletions Side-by-side Diff

devlolhackerspaceapi.py
... ... @@ -38,6 +38,7 @@
38 38 client.end_headers()
39 39  
40 40 def do_GET(self):
  41 + global r
41 42 if self.path == "/":
42 43 self.send_response(200)
43 44 self.send_header("Content-type", "application/json")
... ... @@ -46,6 +47,14 @@
46 47 self.wfile.write(str.encode(generate_hackerspaceapi_json()))
47 48 except BrokenPipeError:
48 49 pass
  50 + elif self.path == "/openstatus":
  51 + self.send_response(302)
  52 + if str(r.get('devlol/h19/door/lockstatus'),'utf-8') == 'UNLOCKED':
  53 + self.send_header('Location','https://devlol.org/wiki/DevLoL?action=AttachFile&do=get&target=open.png')
  54 + else:
  55 + self.send_header('Location','https://devlol.org/wiki/DevLoL?action=AttachFile&do=get&target=closed.png')
  56 + self.end_headers()
  57 +
49 58  
50 59 def on_message(client, userdata, msg):
51 60 global r