Browse Source

Server now serves HTML to localhost:5001 :gun:

And we automatically pop a browser window when the server boots. Nice
master
Pete Shadbolt 8 years ago
parent
commit
60a5a22c06
14 changed files with 18 additions and 4 deletions
  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 View File

@@ -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 View File


client/api.js → static/api.js View File


client/curve.js → static/curve.js View File


client/graph.js → static/graph.js View File


client/index.html → static/index.html View File


client/interaction.js → static/interaction.js View File


client/libs.js → static/libs.js View File


client/main.css → static/main.css View File


client/main.js → static/main.js View File


client/materials.js → static/materials.js View File


client/poll.js → static/poll.js View File


client/tables.js → static/tables.js View File


client/three.js → static/three.js View File


Loading…
Cancel
Save