gevent-websocket

1191 단어 websocket
gevent - websocket 은 gevent 를 사용 하 는 websocket 입 니 다. 주소:http://www.gelens.org/code/gevent-websocket/
 
import sys, os
import memcache
import gevent
from gevent import wsgi
from gevent import socket
import geventwebsocket
from gevent import monkey

monkey.patch_all() 
mc = memcache.Client(['127.0.0.1:11211'], debug=1)

def echo(environ, start_response):
    websocket = environ.get("wsgi.websocket")
    #print websocket
    return http_handler(environ, start_response)

def http_handler(environ, start_response):
    start_response("200 OK", [])
    mc.set('test1','test1',10)
    print mc.get('test1')
    return ['hello gevent']
         
path = os.path.dirname(geventwebsocket.__file__)
agent = "gevent-websocket/%s" % (geventwebsocket.__version__)
print "Running %s from %s" % (agent, path)         
ws_server = gevent.pywsgi.WSGIServer(('', 8000), echo,handler_class=geventwebsocket.WebSocketHandler)
ws_server.serve_forever()

좋은 웹페이지 즐겨찾기