浏览代码

Threaded HTTP server -> no laggy refresh

master
Pete Shadbolt 8 年前
父节点
当前提交
452430627a
共有 4 个文件被更改,包括 14 次插入9 次删除
  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 查看文件

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

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

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

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


+ 7
- 7
static/index.html 查看文件

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

<div id=node_data class=hidden>
<h3 id=node_name></h3>
<div id=node_name></div>
<ul>
<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>-->
<!--<a href="#">IA</a>-->
<!--<a href="#">IB</a>-->


+ 1
- 0
static/main.css 查看文件

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

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




+ 1
- 1
static/scripts/materials.js 查看文件

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


正在加载...
取消
保存