Welcome to the EVENTWIRED Framework!

A lightweight, async-first framework built with modern web development in mind.

Get Started

GitHub

Drafty documentation can be found at demo_app/docs

Example Routes:

Define routes easily with Python:

from demo_app.controllers.welcome_controller import welcome_controller

def register_routes(routing_service):
    routing_service.add_route('/', 'GET', welcome_controller)
        

Example Controllers:

Controllers are simple functions that return a response:

from src.controllers.base_controller import BaseController
from src.event_bus import Event
from demo_app.di_setup import di_container

async def welcome_controller(event: Event):
    controller = BaseController(event)
    template_service = await di_container.get('TemplateService')
    rendered_content = template_service.render_template('welcome.html', {})
    await controller.send_html(rendered_content)
        

Example Templates:

Templates are rendered using Jinja2/Mako2:

The template is this one :P

Chat Room Feature:

The app includes a real-time chat room available at /chat_room. You can easily create a chat room with just a few lines of code:

from src.controllers.websocket_controller import WebSocketController
from src.event_bus import Event

async def chat_room_controller(event: Event):
    websocket_service = await di_container.get('WebSocketService')
    controller = WebSocketController(event)
    websocket_service.register_client(controller)

    async def on_message(message):
        if message not in {"websocket.connect", "websocket.disconnect"}:
            broadcast_message = f"User: {message}"
            await websocket_service.broadcast_message(broadcast_message)

    await websocket_service.accept_client_connection(controller)
    await websocket_service.listen(controller, on_message)
    

This, along with a template and route setup, is all you need for a working chat room.

Note: Everything a developer needs to know is in the demo_app folder, which serves as the example to follow. The src folder contains the internals of the framework.