Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ndendic/starHTML

 
 

Repository files navigation

StarHTML

A Python-first hypermedia framework, forked from FastHTML. Uses Datastar instead of HTMX for the same hypermedia-driven approach with a different flavor.

Installation

pip install starhtml

Quick Start

from starhtml import *
from starhtml.datastar import ds_text, ds_on_click, ds_signals

app, rt = star_app()

@rt('/')
def home(): 
    return Div(
        H1("StarHTML Demo"),
        # Client-side reactivity with signals
        Div(
            P("Count: ", Span(ds_text("$count"))),
            Button("++", ds_on_click("$count++")),
            Button("Reset", ds_on_click("$count = 0")),
            ds_signals(count=0)
        ),
        
        # Server-side interactions
        Button("Load Data", ds_on_click("@get('/api/data')")),
        Div(id="content")
    )

@rt('/api/data')
def get():
    return Div("Data loaded from server!", id="content")

serve()

Run with python main.py and visit http://localhost:5001.

What's Different?

FastHTML StarHTML
HTMX for server interactions Datastar for reactive UI
Built with nbdev notebooks Standard Python modules
Multiple JS extensions Single reactive framework
WebSockets for real-time SSE for real-time

Development

git clone https://github.com/banditburai/starhtml.git
cd starhtml
uv sync  # or pip install -e ".[dev]"
pytest && ruff check .

Links


StarHTML is a respectful fork of FastHTML. We're grateful to the FastHTML team for the excellent foundation.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 89.7%
  • TypeScript 6.4%
  • HTML 1.3%
  • CSS 1.3%
  • Other 1.3%