2
from eventlet import wsgi
3
from eventlet import websocket
7
@websocket.WebSocketWSGI
15
for p in participants:
18
participants.remove(ws)
20
def dispatch(environ, start_response):
21
"""Resolves to the web page or the websocket depending on the path."""
22
if environ['PATH_INFO'] == '/chat':
23
return handle(environ, start_response)
25
start_response('200 OK', [('content-type', 'text/html')])
26
return [open(os.path.join(
27
os.path.dirname(__file__),
28
'websocket_chat.html')).read()]
30
if __name__ == "__main__":
31
# run an example app from the command line
32
listener = eventlet.listen(('127.0.0.1', 7000))
33
print "\nVisit http://localhost:7000/ in your websocket-capable browser.\n"
34
wsgi.server(listener, dispatch)