瀏覽代碼

Server now serves HTML to localhost:5001 :gun:

And we automatically pop a browser window when the server boots. Nice
master
Pete Shadbolt 8 年之前
父節點
當前提交
60a5a22c06
共有 14 個檔案被更改,包括 18 行新增4 行删除
  1. +18
    -4
      abp/server.py
  2. +0
    -0
      static/anders_briegel.js
  3. +0
    -0
      static/api.js
  4. +0
    -0
      static/curve.js
  5. +0
    -0
      static/graph.js
  6. +0
    -0
      static/index.html
  7. +0
    -0
      static/interaction.js
  8. +0
    -0
      static/libs.js
  9. +0
    -0
      static/main.css
  10. +0
    -0
      static/main.js
  11. +0
    -0
      static/materials.js
  12. +0
    -0
      static/poll.js
  13. +0
    -0
      static/tables.js
  14. +0
    -0
      static/three.js

+ 18
- 4
abp/server.py 查看文件

@@ -1,7 +1,8 @@
import json
from websocket_server import WebsocketServer
import abp

from SimpleHTTPServer import SimpleHTTPRequestHandler
from BaseHTTPServer import HTTPServer
import os, sys, threading, time
import webbrowser

clients = []

@@ -18,10 +19,23 @@ def client_left(client, server):
clients.remove(client)

if __name__ == '__main__':
# Change to the right working dir
where = os.path.join(sys.path[0], "../static")
os.chdir(where)

# Start the HTTP server
httpserver = HTTPServer(('', 5001), SimpleHTTPRequestHandler)
thread = threading.Thread(target = httpserver.serve_forever)
thread.daemon = True
thread.start()
time.sleep(2)
webbrowser.open("http://localhost:5001/")

# Start the websocket server
server = WebsocketServer(5000)
server.set_fn_new_client(new_client)
server.set_fn_message_received(new_message)
server.set_fn_client_left(client_left)
server.run_forever()

httpserver.shutdown()


client/anders_briegel.js → static/anders_briegel.js 查看文件


client/api.js → static/api.js 查看文件


client/curve.js → static/curve.js 查看文件


client/graph.js → static/graph.js 查看文件


client/index.html → static/index.html 查看文件


client/interaction.js → static/interaction.js 查看文件


client/libs.js → static/libs.js 查看文件


client/main.css → static/main.css 查看文件


client/main.js → static/main.js 查看文件


client/materials.js → static/materials.js 查看文件


client/poll.js → static/poll.js 查看文件


client/tables.js → static/tables.js 查看文件


client/three.js → static/three.js 查看文件


Loading…
取消
儲存