$ show abersheeran/kui
Kuí is a lightweight Python web framework that supports both ASGI (async) and WSGI (sync) modes with a nearly identical API. It provides type-safe parameter binding via typing_extensions.Annotated and Pydantic, dependency injection with caching and cleanup, automatic OpenAPI 3.1.0 documentation generation, middleware composition, class-based views for HTTP and WebSocket, background task execution, CORS support, authentication helpers (Bearer, Basic, API Key), and template rendering with Jinja2. The framework is built on baize and emphasizes developer experience through clear documentation and AI-assisted development support.
The LLM identified 3 files worth highlighting for reuse:
Provides BackgroundTask and BackgroundTasks classes for managing asynchronous background operations. Completely framework-independent with only standard library dependencies, this component solves the common problem of executing cleanup or follow-up tasks after HTTP responses are sent. Demonstrates proper async resource management using AsyncExitStack and clean separation of concerns.
Implements a thread-safe and async-safe state container that extends dict with automatic locking. Provides both synchronous (__enter__/__exit__) and asynchronous (__aenter__/__aexit__) context managers for safe concurrent access. Zero external dependencies beyond standard library threading and asyncio, making it universally reusable in any Python application requiring shared state management.
Offers bind_contextvar function and context_setter contextmanager for safe context variable manipulation. Eliminates boilerplate when working with contextvars by providing attribute and item access patterns on bound variables. Self-contained with only standard library dependencies, this utility simplifies context-dependent programming in asynchronous applications.