Browse Source

Threaded HTTP server -> no laggy refresh

master
Pete Shadbolt 8 years ago
parent
commit
452430627a
4 changed files with 14 additions and 9 deletions
  1. +5
    -1
      abp/server.py
  2. +7
    -7
      static/index.html
  3. +1
    -0
      static/main.css
  4. +1
    -1
      static/scripts/materials.js

+ 5
- 1
abp/server.py View File

@@ -1,6 +1,7 @@
from websocket_server import WebsocketServer from websocket_server import WebsocketServer
from SimpleHTTPServer import SimpleHTTPRequestHandler from SimpleHTTPServer import SimpleHTTPRequestHandler
from BaseHTTPServer import HTTPServer from BaseHTTPServer import HTTPServer
from SocketServer import ThreadingMixIn
import os, sys, threading import os, sys, threading
import webbrowser import webbrowser
import argparse import argparse
@@ -19,6 +20,9 @@ def client_left(client, server):
print "Client {} disconnected.".format(client["id"]) print "Client {} disconnected.".format(client["id"])
clients.remove(client) clients.remove(client)


class ThreadedHTTPServer(ThreadingMixIn, HTTPServer):
""" Handle requests in a separate thread """

if __name__ == '__main__': if __name__ == '__main__':
parser = argparse.ArgumentParser(description = "ABP websocket server") parser = argparse.ArgumentParser(description = "ABP websocket server")
parser.add_argument("-v", action="store_false", help="Launch browser") parser.add_argument("-v", action="store_false", help="Launch browser")
@@ -29,7 +33,7 @@ if __name__ == '__main__':
os.chdir(where) os.chdir(where)


# Start the HTTP server # Start the HTTP server
httpserver = HTTPServer(('', 5001), SimpleHTTPRequestHandler)
httpserver = ThreadedHTTPServer(('', 5001), SimpleHTTPRequestHandler)
thread = threading.Thread(target = httpserver.serve_forever) thread = threading.Thread(target = httpserver.serve_forever)
thread.daemon = True thread.daemon = True
thread.start() thread.start()


+ 7
- 7
static/index.html View File

@@ -26,15 +26,15 @@
<div id=server_info class=hidden> </div> <div id=server_info class=hidden> </div>


<div id=node_data class=hidden> <div id=node_data class=hidden>
<h3 id=node_name></h3>
<div id=node_name></div>
<ul> <ul>
<li id=node_vop></li> <li id=node_vop></li>
<li><a href="#">Measure in X</a></li>
<li><a href="#">Measure in Y</a></li>
<li><a href="#">Measure in Z</a></li>
<li><a href="#">Act Hadamard</a></li>
<li><a href="#">Act Phase</a></li>
<li><a href="#" onclick="editor.localComplementation()">Invert neighbourhood</a></li>
<!--<li><a href="#">Measure in X</a></li>-->
<!--<li><a href="#">Measure in Y</a></li>-->
<!--<li><a href="#">Measure in Z</a></li>-->
<!--<li><a href="#">Act Hadamard</a></li>-->
<!--<li><a href="#">Act Phase</a></li>-->
<!--<li><a href="#" onclick="editor.localComplementation()">Invert neighbourhood</a></li>-->
<!--<li>--> <!--<li>-->
<!--<a href="#">IA</a>--> <!--<a href="#">IA</a>-->
<!--<a href="#">IB</a>--> <!--<a href="#">IB</a>-->


+ 1
- 0
static/main.css View File

@@ -47,6 +47,7 @@ ul {


li{ li{
padding:3px; padding:3px;
padding-left: 0em;
} }






+ 1
- 1
static/scripts/materials.js View File

@@ -14,7 +14,7 @@ materials.prepare = function() {
linewidth: 2 linewidth: 2
}); });
materials.qubit = new THREE.PointsMaterial({ materials.qubit = new THREE.PointsMaterial({
size: 0.5,
size: 0.3,
map: ballSprite, map: ballSprite,
alphaTest: 0.5, alphaTest: 0.5,
transparent: true, transparent: true,


Loading…
Cancel
Save