WebSockets for bottle
Project description
Bottle Tornado Websocket
========================
This project adds websocket capabilities to [bottle](http://bottlepy.org), leveraging [tornado](http://www.tornadoweb.org/)
### Install
Use `pip` or `easy_install`:
pip install bottle-tornado-websocket
### Requirements
* Bottle
* Tornado
### Usage
Import the server and tornado's WebSocketHandler:
from bottle.ext.tornado.websocket import TornadoWebSocketServer
from tornado.websocket import WebSocketHandler
Create 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 = [
(r"/echo", EchoWebSocket)
]
Note: the `.*` is automatically mapped as a last handler to your normal bottle application
And then use the provided server:
run(port=8080, server=TornadoWebSocketServer, handlers=tornado_handlers)
### Example
To echo chat example just run `chat.py` in `examples/echo` folder:
python echo.py
To run chat example just run `chat.py` in `examples/chat` folder:
python chat.py
========================
This project adds websocket capabilities to [bottle](http://bottlepy.org), leveraging [tornado](http://www.tornadoweb.org/)
### Install
Use `pip` or `easy_install`:
pip install bottle-tornado-websocket
### Requirements
* Bottle
* Tornado
### Usage
Import the server and tornado's WebSocketHandler:
from bottle.ext.tornado.websocket import TornadoWebSocketServer
from tornado.websocket import WebSocketHandler
Create 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 = [
(r"/echo", EchoWebSocket)
]
Note: the `.*` is automatically mapped as a last handler to your normal bottle application
And then use the provided server:
run(port=8080, server=TornadoWebSocketServer, handlers=tornado_handlers)
### Example
To echo chat example just run `chat.py` in `examples/echo` folder:
python echo.py
To run chat example just run `chat.py` in `examples/chat` folder:
python chat.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for bottle-tornado-websocket-0.12.zip
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1069911edc054bc2d308048be5d1477672259ea1f46034932d190ff382b8bb43 |
|
MD5 | 734b1c7bb63ad6a432af64d94aa14cb0 |
|
BLAKE2b-256 | df3169ada93c57c136e22685c9266c85072541083e8082099e8a9e9d6c4a6f65 |