4 from eventlet import wsgi
5 from eventlet import websocket
12 @websocket.WebSocketWSGI
20 for p in participants:
23 participants.remove(ws)
26 def dispatch(environ, start_response):
27 """Resolves to the web page or the websocket depending on the path."""
28 if environ['PATH_INFO'] == '/chat':
29 return handle(environ, start_response)
31 start_response('200 OK', [('content-type', 'text/html')])
32 html_path = os.path.join(os.path.dirname(__file__), 'websocket_chat.html')
33 return [open(html_path).read() % {'port': PORT}]
35 if __name__ == "__main__":
36 # run an example app from the command line
37 listener = eventlet.listen(('127.0.0.1', PORT))
38 print("\nVisit http://localhost:7000/ in your websocket-capable browser.\n")
39 wsgi.server(listener, dispatch)