我正在使用geventwebsockets,但甚至無法獲得示例應用程序的工作。下面的代碼給我的錯誤:如何獲得gevent websockets的工作?
Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line 884, in handle_one_response self.run_application() File "/usr/local/lib/python2.7/dist-packages/geventwebsocket/handler.py", line 88, in run_application return super(WebSocketHandler, self).run_application() File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line 870, in run_application self.result = self.application(self.environ, self.start_response) File "/usr/local/lib/python2.7/dist-packages/geventwebsocket/resource.py", line 90, in call raise Exception("No apps defined") Exception: No apps defined
from geventwebsocket import WebSocketServer, WebSocketApplication, Resource
class EchoApplication(WebSocketApplication):
def on_open(self):
print "Connection opened"
def on_message(self, message):
self.ws.send(message)
def on_close(self, reason):
print reason
WebSocketServer(
('', 8000),
Resource({'/': EchoApplication})
).serve_forever()
我已經手忙腳亂。誰能幫我嗎?非常感謝。