diff options
| author | Ryan Williams <breath@alum.mit.edu> | 2010-05-22 14:19:30 -0700 |
|---|---|---|
| committer | Ryan Williams <breath@alum.mit.edu> | 2010-05-22 14:19:30 -0700 |
| commit | 800883ee1bd3cc4eaaabbc81495b79610983fbc9 (patch) | |
| tree | d9f640d851c9f86e1c7a27e2d4785065b90b9993 /examples | |
| parent | 0363e0b40a6cd5320b1c31b04ed308bd4814480f (diff) | |
| download | eventlet-800883ee1bd3cc4eaaabbc81495b79610983fbc9.tar.gz | |
Added documentation for websocket module and switched to using decorators in the examples.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/websocket.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/examples/websocket.py b/examples/websocket.py index 9bac0e2..ae8181f 100644 --- a/examples/websocket.py +++ b/examples/websocket.py @@ -5,6 +5,8 @@ from eventlet import websocket # demo app import os import random + +@websocket.WebSocketWSGI def handle(ws): """ This is the websocket handler function. Note that we can dispatch based on path in here, too.""" @@ -20,12 +22,11 @@ def handle(ws): ws.send("0 %s %s\n" % (i, random.random())) eventlet.sleep(0.1) -wsapp = websocket.WebSocketWSGI(handle) def dispatch(environ, start_response): """ This resolves to the web page or the websocket depending on the path.""" if environ['PATH_INFO'] == '/data': - return wsapp(environ, start_response) + return handle(environ, start_response) else: start_response('200 OK', [('content-type', 'text/html')]) return [open(os.path.join( |
