From 13b99667fa35ee913c314d5ec0cdb51d5835a98a Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Sat, 17 Feb 2018 16:40:12 +0000 Subject: Integrate websockets into the Flask webapp --- ws_app.py | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 ws_app.py (limited to 'ws_app.py') diff --git a/ws_app.py b/ws_app.py deleted file mode 100644 index cab43ac0..00000000 --- a/ws_app.py +++ /dev/null @@ -1,28 +0,0 @@ -# coding=utf-8 -import os - -from geventwebsocket import Resource, WebSocketApplication, WebSocketServer - - -class EchoApplication(WebSocketApplication): - def on_open(self): - print("Connection opened") - - def on_message(self, message, **kwargs): - print(f"<- {message}") - self.ws.send(message) - print(f"-> {message}") - - def on_close(self, reason): - print(reason) - - -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() -- cgit v1.2.3