Skip to content

kriuchkov/sockjs-flask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SockJS server for Flask ============

Latest PyPI version

Latest Travis CI build status

sockjs is a SockJS integration for Flask. SockJS interface is implemented as a flask route. Its possible to create any number of different sockjs routes, ie /sockjs/* or /mycustom-sockjs/*. You can provide different session implementation and management for each sockjs route.

Usage

Client side code:

<script src="//cdnjs.cloudflare.com/ajax/libs/sockjs-client/1.1.4/sockjs.js"></script>
<script>
    var sock = new SockJS('http://localhost:5000/sockjs');

    sock.onopen = function() {
      console.log('open');
    };

    sock.onmessage = function(obj) {
      console.log(obj);
    };

    sock.onclose = function() {
      console.log('close');
    };
</script>

Installation

  1. Install virtualenv:

    $ wget https://raw.github.com/pypa/virtualenv/master/virtualenv.py
    $ python3.6 ./virtualenv.py --no-site-packages sockjs
  2. Install sockjs-flask from pypi and then install:

    $ pip install sockjs-flask
    $ cd sockjs
    $ ../sockjs/bin/python setup.py

To run chat example use following command:

$ ./sockjs/bin/python ./sockjs-flask/examples/main.py

Requirements

  • Python >= 3.4
  • gunicorn
  • gevent
  • gevent-websocket
  • kombu (for subscription)

Authors

sockjs-flask was written by Kryuchkov Nikita.

About

sockjs server for Flask with gevent

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published