Skip to main content

Modern HTML generation in Python, inspired by FastHTML

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

starhtml-0.1.20.tar.gz (393.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

starhtml-0.1.20-py3-none-any.whl (89.3 kB view details)

Uploaded Python 3

File details

Details for the file starhtml-0.1.20.tar.gz.

File metadata

  • Download URL: starhtml-0.1.20.tar.gz
  • Upload date:
  • Size: 393.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for starhtml-0.1.20.tar.gz
Algorithm Hash digest
SHA256 e8ae85062f899427b14843288d9d6737afd93ed7970b9728a0a05f4e61260d8f
MD5 d0be2d56a150360b15bc9c547b1a0310
BLAKE2b-256 e72fb0e6710998ed4cd86fcc222bfe01123b01849c1cde1357a1bfb7c453157c

See more details on using hashes here.

Provenance

The following attestation bundles were made for starhtml-0.1.20.tar.gz:

Publisher: release.yml on banditburai/starHTML

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file starhtml-0.1.20-py3-none-any.whl.

File metadata

  • Download URL: starhtml-0.1.20-py3-none-any.whl
  • Upload date:
  • Size: 89.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for starhtml-0.1.20-py3-none-any.whl
Algorithm Hash digest
SHA256 01f3f5277ec3f3d0c848b027ff5d2bd33eb7b00249aacc8bc135f4bda329fb13
MD5 0488c85a7a45fdf15ac4b0cadf65f24a
BLAKE2b-256 5f4e4609e5f208c7ab0fa378d2b90ea1ecaef42f6870299f1b43495be151f3a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for starhtml-0.1.20-py3-none-any.whl:

Publisher: release.yml on banditburai/starHTML

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page