from rainbow import register, publish, run @register def add(a=0, b=1.2, c=False, d={"item": True}, l=[1, 2, 3]): """Add a + b""" publish('event.add', '{0} + {1}'.format(a, b)) return a + b @register def sub(a=0, b=3, text="text"): """Subtract a - b""" publish('event.sub', '{0} - {1}'.format(a, b)) return a - b run(host='0.0.0.0', avahi=True, webserver=True) # sudo required
from rainbow import register, run @register def add(a=0, b=0): return a + b run(host='0.0.0.0', webserver=True, webbrowser=True)
from rainbow import register, publish, run @register def pub(): publish('event', 1234) run(host='0.0.0.0')
from rainbow import register, run @register def add(a=0, b=0): return a + b run(host='0.0.0.0', webserver=True)
import time import threading from rainbow import register, publish, run running = False @register 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 def stop(): global running running = False run(host='0.0.0.0')
from rainbow import register, publish, run @register def test0(): "Publish an event" publish("event", {"v": 3.14}) @register def test1(a=0, b=0.0): """Add two elements""" return a + b @register def test2(a="", b=True): return "{0} {1}".format(a, b) @register def test3(l=[1, False, {"item": 12}]): for i in l: print(i) return "OK" run(host="0.0.0.0", webserver=True, webbrowser=True)
from rainbow import register, publish, run @register def test0(): "Publish an event" publish('event', {'v': 3.14}) @register def test1(a=0, b=0.0): """Add two elements""" return a + b @register def test2(a='', b=True): return '{0} {1}'.format(a, b) @register def test3(l=[1, False, {'item': 12}]): for i in l: print(i) return "OK" run(host='0.0.0.0', webserver=True, webbrowser=True)
from rainbow import register, run @register def add(a=2, b=4.5): """Description: add""" return a + b run(host='0.0.0.0', avahi=True) # sudo required