aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2018-02-17 15:46:46 +0000
committerGravatar Gareth Coles <[email protected]>2018-02-17 15:46:46 +0000
commitdf9326f8e81f5a46cd9fa06638d0cf23ae4407f5 (patch)
tree83a32a913f9d4498275c703c9ec1342864379afc
parentMerge remote-tracking branch 'origin/master' (diff)
Clean up WS application a bit
-rw-r--r--ws_app.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/ws_app.py b/ws_app.py
index a9f60175..8f1f55df 100644
--- a/ws_app.py
+++ b/ws_app.py
@@ -1,6 +1,6 @@
# coding=utf-8
-
from collections import OrderedDict
+import os
from geventwebsocket import Resource, WebSocketApplication, WebSocketServer
@@ -18,10 +18,12 @@ class EchoApplication(WebSocketApplication):
print(reason)
-if __name__ == "__main__":
- app = WebSocketServer(
- ('', 8000),
- Resource(OrderedDict([('/ws/echo', EchoApplication)]))
- )
+app = WebSocketServer(
+ ('', os.environ.get("WS_PORT", 8080)),
+ Resource({
+ "/ws/echo": EchoApplication # Dicts are ordered in Python 3.6
+ })
+)
+if __name__ == "__main__":
app.serve_forever()