Skip to content
forked from Jesus89/rainbow

Micro-framework for Python RPC+P&S over WebSockets

License

Notifications You must be signed in to change notification settings

gvJaime/rainbow

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rainbow

License Build Status

Work in progress

Micro-framework for Python RPC+P&S communication over WebSockets

Installation

sudo apt-get install python-dev libzmq-dev
python setup.py install

Example

Basic Example

from rainbow import register, run

@register('add')
def add(a, b):
    return a + b

run(host='0.0.0.0')

Publish Example

from rainbow import register, publish, run

@register('pub')
def pub():
    publish('event', 'data')

run(host='0.0.0.0')

Threading example

import time
import threading
from rainbow import register, publish, run

running = False

@register('start')
def start():
    global running
    if not running:
        running = True
        threading.Thread(target=_start).start()

def _start():
    global running
    while running:
        print "Hello, world!"
        publish('event.hello', "Hello, world!")
        time.sleep(3)

@register('stop')
def stop():
    global running
    running = False

run(host='0.0.0.0')

About

Micro-framework for Python RPC+P&S over WebSockets

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 81.2%
  • HTML 18.8%