|
@@ -7,6 +7,8 @@ import json |
|
|
import threading |
|
|
import threading |
|
|
import time |
|
|
import time |
|
|
|
|
|
|
|
|
|
|
|
state = 0 |
|
|
|
|
|
|
|
|
class VizHandler(SimpleHTTPRequestHandler): |
|
|
class VizHandler(SimpleHTTPRequestHandler): |
|
|
""" Handles requests to the server """ |
|
|
""" Handles requests to the server """ |
|
|
def __init__(self, *args, **kwargs): |
|
|
def __init__(self, *args, **kwargs): |
|
@@ -16,7 +18,7 @@ class VizHandler(SimpleHTTPRequestHandler): |
|
|
self.send_response(200) |
|
|
self.send_response(200) |
|
|
self.send_header('Content-Type', 'application/json') |
|
|
self.send_header('Content-Type', 'application/json') |
|
|
self.end_headers() |
|
|
self.end_headers() |
|
|
self.wfile.write(json.dumps({"state":"here is the state"})) |
|
|
|
|
|
|
|
|
self.wfile.write(json.dumps({"state":"{}".format(state)})) |
|
|
|
|
|
|
|
|
def do_GET(self, *args, **kwargs): |
|
|
def do_GET(self, *args, **kwargs): |
|
|
parsed_path = urlparse.urlparse(self.path) |
|
|
parsed_path = urlparse.urlparse(self.path) |
|
@@ -49,5 +51,7 @@ class VizServer(SocketServer.TCPServer): |
|
|
if __name__ == '__main__': |
|
|
if __name__ == '__main__': |
|
|
server = VizServer() |
|
|
server = VizServer() |
|
|
server.start() |
|
|
server.start() |
|
|
time.sleep(5) |
|
|
|
|
|
|
|
|
while True: |
|
|
|
|
|
state += 1 |
|
|
|
|
|
time.sleep(1) |
|
|
server.shutdown() |
|
|
server.shutdown() |