Skip to main content
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_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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bottle-tornado-websocket-0.13.zip (5.4 kB view details)

Uploaded Source

File details

Details for the file bottle-tornado-websocket-0.13.zip.

File metadata

File hashes

Hashes for bottle-tornado-websocket-0.13.zip
Algorithm Hash digest
SHA256 b3a0002c2a44c06af99e759b188eeada6b39877222c1bc96bd22b876b5d90daa
MD5 ca8ce9b284675df305d09c46b7f63b0d
BLAKE2b-256 a78a04cac82c02cc7031361e850f516732f78aa25727ed1245931276616af3b0

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.13 This release

1 file

0.12

1 file

0.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page