Skip to main content

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.tornadosocket 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


Download files

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

Source Distribution

bottle-tornadosocket-0.13.zip (5.3 kB view details)

Uploaded Source

File details

Details for the file bottle-tornadosocket-0.13.zip.

File metadata

File hashes

Hashes for bottle-tornadosocket-0.13.zip
Algorithm Hash digest
SHA256 77b5953bdcf9e6931a90538ee018da5f592a84f8b7fc6f852c441a5230a0072b
MD5 f7c957b7955188f8be00b88767491f7f
BLAKE2b-256 29691cbe0cca44075b37da92e02e27f0edb77d74b612d565f92f7c35a9c5c80b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page