X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=eventlet%2Fexamples%2Fwebsocket_chat.py;fp=eventlet%2Fexamples%2Fwebsocket_chat.py;h=0000000000000000000000000000000000000000;hb=358bd9258c2b6d2ee74de4dfd07a5123107abad4;hp=3866674f60a6eca4a896fd5afd7621fd28513e3d;hpb=376ff3bfe7071cc0793184a378c4e74508fb0d97;p=packages%2Ftrusty%2Fpython-eventlet.git diff --git a/eventlet/examples/websocket_chat.py b/eventlet/examples/websocket_chat.py deleted file mode 100644 index 3866674..0000000 --- a/eventlet/examples/websocket_chat.py +++ /dev/null @@ -1,39 +0,0 @@ -import os - -import eventlet -from eventlet import wsgi -from eventlet import websocket - -PORT = 7000 - -participants = set() - - -@websocket.WebSocketWSGI -def handle(ws): - participants.add(ws) - try: - while True: - m = ws.wait() - if m is None: - break - for p in participants: - p.send(m) - finally: - participants.remove(ws) - - -def dispatch(environ, start_response): - """Resolves to the web page or the websocket depending on the path.""" - if environ['PATH_INFO'] == '/chat': - return handle(environ, start_response) - else: - start_response('200 OK', [('content-type', 'text/html')]) - html_path = os.path.join(os.path.dirname(__file__), 'websocket_chat.html') - return [open(html_path).read() % {'port': PORT}] - -if __name__ == "__main__": - # run an example app from the command line - listener = eventlet.listen(('127.0.0.1', PORT)) - print("\nVisit http://localhost:7000/ in your websocket-capable browser.\n") - wsgi.server(listener, dispatch)