LazyFast is a lightweight Python library for building modern, component-based web interfaces using FastAPI. It handles server-side logic in Python, with interactive elements like inputs and buttons triggering server-side component reloads for dynamic state updates.
Ideal for Python developers who:
- Have basic HTML and CSS knowledge and want to build web interfaces without learning complex frontend frameworks like React, Angular, or Vue.
Suitable for projects that:
- Have low to medium traffic and can benefit from server-side rendering to offload work from the client's machine. (Note: High traffic may increase server costs due to backend load.)
- Require quick prototyping and demos without involving frontend developers. LazyFast offers more flexibility than tools like Streamlit, which can be limiting and produce similar-looking applications.
Key Features
- Component-Based Server Rendering
- Build interfaces with lazy-loaded components that encapsulate logic, state, and presentation.
- Server-Side Logic
- Manage interactions and state on the server, reducing client-side complexity.
- FastAPI Integration
- Components and pages are FastAPI endpoints, supporting dependency injection and other features.
- Lightweight
- Dependencies: FastAPI for Python and HTMX for JavaScript (included via CDN).
- State Management
- Use a state manager to trigger component reloads for a reactive user experience.
Installation
To install LazyFast, use pip:
pip install lazyfast
or
poetry add lazyfast
Quick Start
Here's an example application to demonstrate how LazyFast works:
from fastapi import FastAPI, Request
from lazyfast import LazyFastRouter, Component, tags
# LazyFastRouter inherits from FastAPI's APIRouter
router = LazyFastRouter()
# Define a lazy-loaded HTML component powered by HTMX
@router.component()
class MyComponent(Component):
title: str
async def view(self, request: Request) -> None:
tags.h1(self.title, class_="my-class")
with tags.div(style="border: 1px solid black"):
tags.span(request.headers)
# Initialize the page dependencies for component rendering
# The page endpoint is also a FastAPI endpoint
@router.page("/{name}")
def root(name: str):
with tags.div(class_="container mt-6"):
MyComponent(title=f"Hello, World from {name}")
# Embed the router in a FastAPI app
app = FastAPI()
app.include_router(router)
If you use uvicorn instead as a server and want to reload on changes, use the following command:
uvicorn app:app --reload --timeout-graceful-shutdown 1
License
LazyFast is licensed under the MIT License.
Roadmap
- Cache system for HTML tags
- Component templates with popular CSS frameworks (Bootstrap, Bulma, etc.)
- Advanced state management
- Closer integration with HTMX
- ...
Metadata
Release files for lazyfast 0.1.32
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lazyfast-0.1.32.tar.gz | 18.8 kB | Without provenance | Details for lazyfast-0.1.32.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lazyfast-0.1.32-py3-none-any.whl | Python 3 | none | any | Details for lazyfast-0.1.32-py3-none-any.whl |
Total release size: 38.5 kB
Release files / lazyfast-0.1.32.tar.gz
| Download URL | lazyfast-0.1.32.tar.gz |
|---|---|
| Size | 18.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d03dc09ad3e543dac0086b6597267ac7c9a98f8098f3b5ab358f0211ea67acee
|
|
BLAKE2b-256 checksum How to use checksums |
509a44144422cc7a545543031f51c1e5f145b02b83b0415013ef35e536b54c5d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.10.6 Linux/5.15.153.1-microsoft-standard-WSL2
|
Release files / lazyfast-0.1.32-py3-none-any.whl
| Download URL | lazyfast-0.1.32-py3-none-any.whl |
|---|---|
| Size | 19.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
deee98bc698db3247fc6132fdefd5f0be7b2e5b54f1552df81f922777ff1b44d
|
|
BLAKE2b-256 checksum How to use checksums |
a86a0fc4bf5e1b6b56957f04d4de42937e100012eabe6cf6d62512127190f7c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.10.6 Linux/5.15.153.1-microsoft-standard-WSL2
|
Security for lazyfast 0.1.32
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.