-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpushmeplease.py
executable file
·35 lines (29 loc) · 985 Bytes
/
pushmeplease.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
#!/usr/bin/env python3
from http.server import BaseHTTPRequestHandler, HTTPServer
import sys
import wxpaper
class S(BaseHTTPRequestHandler):
def _set_headers(self):
self.send_response(200)
self.send_header("Content-type", "text/plain")
self.end_headers()
def do_GET(self):
self._set_headers()
if self.path == "/pushmeplease":
print("got push request")
try:
wxpaper.do_update()
except Exception as ex:
print("something went wrong calling wxpaper")
print(ex)
pass
else:
print("got invalid request")
self.wfile.write(b"go away\n")
def run(server_class=HTTPServer, handler_class=S, port=33223):
server_address = ("", port)
httpd = server_class(server_address, handler_class)
print(f"Starting httpd listening on port {port}...")
httpd.serve_forever()
if __name__ == "__main__":
run()