2019-08-11 10:05:05 +00:00
|
|
|
from http.server import BaseHTTPRequestHandler, HTTPServer
|
|
|
|
|
|
|
|
import os
|
2020-02-09 17:18:02 +00:00
|
|
|
import socket
|
2020-02-10 18:33:34 +00:00
|
|
|
from time import sleep
|
2019-08-11 10:05:05 +00:00
|
|
|
|
|
|
|
"""
|
|
|
|
GetBlue Android parameters
|
|
|
|
Host: http://IP_DU_PC:8080
|
|
|
|
Parameter for data: data
|
|
|
|
Parameter for timestamp: timestamp
|
|
|
|
HTTP request: GET
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
class Server(BaseHTTPRequestHandler):
|
|
|
|
def _set_headers(self):
|
|
|
|
self.send_response(200)
|
|
|
|
self.send_header('Content-type', 'text/html')
|
|
|
|
self.end_headers()
|
|
|
|
|
|
|
|
def do_GET(self):
|
|
|
|
self._set_headers()
|
|
|
|
isbn = self.path[7:-24]
|
|
|
|
print("Hey j'ai un ISBN :", isbn)
|
|
|
|
os.system("xdotool type " + isbn)
|
|
|
|
os.system("xdotool key KP_Enter")
|
2020-02-10 18:33:34 +00:00
|
|
|
sleep(1)
|
|
|
|
os.system("xdotool click 1")
|
2019-08-11 10:05:05 +00:00
|
|
|
|
|
|
|
def do_HEAD(self):
|
|
|
|
self._set_headers()
|
|
|
|
|
|
|
|
|
2020-02-09 17:18:02 +00:00
|
|
|
class HTTPServerV6(HTTPServer):
|
|
|
|
address_family = socket.AF_INET6
|
|
|
|
|
|
|
|
|
2019-08-11 10:05:05 +00:00
|
|
|
if __name__ == "__main__":
|
2020-02-09 17:18:02 +00:00
|
|
|
server_address = ('::', 8080)
|
|
|
|
httpd = HTTPServerV6(server_address, Server)
|
2019-08-11 10:05:05 +00:00
|
|
|
print('Starting httpd...')
|
|
|
|
httpd.serve_forever()
|