bottle-tornado-websocketWebSockets for bottle | |
Download |
bottle-tornado-websocket Ranking & Summary
Advertisement
- License:
- Other/Proprietary Li...
- Price:
- FREE
- Publisher Name:
- Cime
- Publisher web site:
- http://www.specialec.net/
bottle-tornado-websocket Tags
bottle-tornado-websocket Description
bottle-tornado-websocket adds websocket capabilities to bottle, leveraging tornado.InstallUse `pip` or `easy_install`: pip install bottle-tornado-websocketUsageImport the server and tornado's WebSocketHandler: from bottle_tornado_websocket import TornadoWebSocketServer from tornado.websocket import WebSocketHandlerCreate your application handlers, for example: class EchoWebSocket(tornado.websocket.WebSocketHandler): def open(self): print 'Connected') def on_message(self, message): self.write(message) def on_close(self): print 'Connection closed')Map handlers to urls: tornado_handlers = Note: the `.*` is automatically mapped as a last handler to your normal bottle applicationAnd then use the provided server: run(port=8080, server=TornadoWebSocketServer, handlers=tornado_handlers)ExampleTo echo chat example just run `chat.py` in `examples/echo` folder: python echo.pyTo run chat example just run `chat.py` in `examples/chat` folder: python chat.pyProduct's homepage
bottle-tornado-websocket Related Software