-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathorviboServer.py
executable file
·42 lines (31 loc) · 1.08 KB
/
orviboServer.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
#!/usr/local/bin/python3
from http.server import BaseHTTPRequestHandler, HTTPServer
from lib.orvibo.orvibo import Orvibo
import urllib.parse
import os.path
import logging
logging.basicConfig()
class GetHandler(BaseHTTPRequestHandler):
def do_GET(self):
parsed_path = urllib.parse.urlparse(self.path)
message = parsed_path.query + " OK "
fname = parsed_path.query +".ir"
if os.path.isfile(fname) :
self.send_response(200)
self.end_headers()
self.wfile.write(bytes(message, "utf8"))
global orv
orv.emit_ir(fname)
else:
message = fname + " not found "
self.send_response(200)
self.end_headers()
self.wfile.write(bytes(message, "utf8"))
return
if __name__ == '__main__':
server = HTTPServer(('', 8081), GetHandler)
global orv
orv = Orvibo('192.168.168.115','accf232991f4', 'irda')
# orv.keep_connection = True
print ('Server in esecuzione, usare <Ctrl-C> per interrompere')
server.serve_forever()