Hello World
The simplest kokage-ui application.
Full Code
"""kokage-ui: Minimal hello world app."""
from fastapi import FastAPI
from kokage_ui import Card, DaisyButton, H1, KokageUI, P, Page
app = FastAPI()
ui = KokageUI(app)
@ui.page("/")
def home():
return Page(
Card(
H1("Hello, World!"),
P("Built with FastAPI + htmx + DaisyUI. Pure Python."),
actions=[DaisyButton("Get Started", color="primary")],
title="Welcome to kokage-ui",
),
title="Hello App",
)
Run
Open http://localhost:8000.
Walkthrough
-
Create a FastAPI app and wrap it with
KokageUI:KokageUI(app)mounts the bundled htmx.js and prepares the page/fragment decorators. -
Define a page route with
@ui.page("/"):This registers a
GET /route that returnsHTMLResponse. -
Return a
Pagewith components:return Page( Card( H1("Hello, World!"), P("Built with FastAPI + htmx + DaisyUI. Pure Python."), actions=[DaisyButton("Get Started", color="primary")], title="Welcome to kokage-ui", ), title="Hello App", )Page(...)generates a full HTML document with all CSS/JS dependenciesCard(...)creates a DaisyUI card with a title, body content, and action buttonsH1,Pare standard HTML elementsDaisyButtonrenders a styled button with DaisyUI classes