Home (original) (raw)

circuits is a Lightweight Event driven and Asynchronous Application Framework for the Python Programming Languagewith a strong Component Architecture.

circuits also includes a lightweight, high performance and scalable HTTP/WSGI compliant web server as well as various I/O and Networking components.

Features*

Examples*

Hello World!

from future import print_function

from circuits import Component, Event

class hello(Event): """hello Event"""

class App(Component):

def hello(self):
    print("Hello World!")

def started(self, component):
    self.fire(hello())
    raise SystemExit(0)

App().run()

A simple Echo Server:

from circuits.net.sockets import TCPServer

class EchoServer(TCPServer):

def read(self, sock, data):
    return data

EchoServer(("0.0.0.0", 8000)).run()

A simple Web Application:

from circuits.web import Server, Controller

class Root(Controller):

def index(self):
    return "Hello World!"

(Server(("0.0.0.0", 9000)) + Root()).run()