Skip to content

Instantly share code, notes, and snippets.

@squeaky-pl
Created January 10, 2014 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save squeaky-pl/8350078 to your computer and use it in GitHub Desktop.
Save squeaky-pl/8350078 to your computer and use it in GitHub Desktop.
# gunicorn -k "geventwebsocket.gunicorn.workers.GeventWebSocketWorker" -w 4 server:handle_request
import gevent
from gevent.monkey import patch_all
from pprint import pprint
from StringIO import StringIO
patch_all()
def handle_request(env, start_response):
websocket = env.get("wsgi.websocket")
if websocket is None:
start_response('200 OK', [('Content-Type', 'text/plain')])
io = StringIO()
pprint(env, io)
return [io.getvalue()]
else:
while True:
message = websocket.receive()
websocket.send(message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment