Skip to content

damonchen/flask-websocket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Flask-WebSocket

copyright: (c) 2017 by Damon Chen. license: BSD, see LICENSE for more details.

simple websocket for Flask

Install

git clone https://github.com/damonchen/flask-websocket/

Usage

you must define message with the follow message if you use on decorator:

{
    "event": event for listen
    "data": the event happend with dtaa
}
from flask import Flask
from flask_websocket import WebSocket

app = Flask(__name__)
ws = WebSocket(app)

@ws.on('click')
def click(data):
    print(data)

or you could process raw message by yourself.

from flask import Flask
from flask_websocket import WebSocket

app = Flask(__name__)
ws = WebSocket(app)


@ws.on_raw_message
def raw_message_handler(message):
    print(message)

About

simple websocket for Flask

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages