Created
August 10, 2015 14:58
-
-
Save ax003d/b530f0c6a9924b7945b3 to your computer and use it in GitHub Desktop.
tornado websocket server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tornado | |
import tornado.websocket | |
class EchoWebSocket(tornado.websocket.WebSocketHandler): | |
def open(self): | |
print("WebSocket opened") | |
def on_message(self, message): | |
print message | |
self.write_message(u"You said: " + message) | |
def on_close(self): | |
print("WebSocket closed") | |
if __name__=='__main__': | |
app = tornado.web.Application([ | |
(r'/', EchoWebSocket), | |
]) | |
app.listen(8000) | |
tornado.ioloop.IOLoop.current().start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment