Skip to main content

HTML builder with server routing for Python

Project description

Sistine

React-like UI framework for Python. Build reactive web UIs with HTML/Tailwind + Alpine.js, powered by Streamlit.

Installation

pip install sistine

Quick Start

from sistine import Sistine, el, fetch

app = Sistine(title="My App")
app.use_tailwind()

@app.sistine("/")
def home():
    return str(
        el.div(cls="min-h-screen bg-gray-50 p-10 flex flex-col items-center")(
            el.h1(cls="text-4xl font-extrabold text-blue-600 mb-8")("Hello Sistine!"),
            el.p(cls="text-gray-600")("Welcome to the future of Python web UI.")
        )
    )

if __name__ == "__main__":
    app.run()
python app.py

Reactive Components (sistine.components)

Sistine provides ready-to-use components with Alpine.js for client-side interactivity — no page reloads needed.

QueryTable — Auto-generated table from API

from sistine.components import QueryTable

QueryTable(
    query="fetch_pokemon",
    columns=["id", "name"],
    params={"limit": 10},
)

QueryDropdown — Select populated from API

from sistine.components import QueryDropdown

QueryDropdown(
    query="fetch_types",
    label_key="name",
    placeholder="Pilih Tipe Pokémon...",
)

QueryView — Reactive data display with auto-refresh

from sistine.components import QueryView

QueryView(
    query="server_status",
    refetch_interval=5,  # auto-refresh every 5s
    children=el.div(cls="text-lg font-bold", x_text="data.cpu")(),
)

QueryList — Iterate over API data

from sistine.components import QueryList

QueryList(
    query="fetch_berries",
    iterator="berry in data",
    template=el.span(cls="badge", x_text="berry.name")(),
)

QueryMutation — POST/PUT/DELETE with confirm dialog

from sistine.components import QueryMutation

QueryMutation(
    query="add_favorite",
    body_js='{ name: "Pikachu" }',
    confirm="Add to favorites?",
    trigger=el.button(cls="bg-yellow-400 text-white px-4 py-2 rounded")("⭐ Favorite"),
)

RefetchButton — Manual refresh

from sistine.components import RefetchButton

RefetchButton(target="fetch_pokemon", label="🔄 Refresh")

Server Queries (@app.query)

Register Python functions as JSON endpoints — callable from browser via sistine.fetch():

from sistine import Sistine, el, fetch

app = Sistine()

@app.query
def fetch_pokemon(limit=10):
    data = fetch(f"https://pokeapi.co/api/v2/pokemon?limit={limit}")
    return data.get("results", [])

@app.query(ttl=60)  # cached for 60s
def get_prices():
    return fetch("https://api.example.com/prices")

@app.sistine("/")
def home():
    return str(
        QueryTable(query="fetch_pokemon", columns=["name"], params={"limit": 5})
    )

Routing

@app.sistine("/")
def home():
    return str(el.h1("Home"))

@app.sistine("/user/{user_id}")
def profile(user_id: int):
    return str(el.h1(f"User {user_id}"))

Navigate via ?route=/user/42 query param, or use el.a(href="/?route=/user/42").

HTML Builder (el)

Chaining syntax — attributes first, children second:

el.div(cls="card p-4 rounded shadow")(
    el.h2(cls="text-xl font-bold")("Title"),
    el.p(cls="text-gray-600")("Description")
)

CSS & Tailwind

app.use_tailwind()
app.css("""
    .custom-class { animation: fadeIn 0.3s ease; }
""")

Examples

Check examples/query_showcase.py for a complete demo of all query components.

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

sistine-0.3.1.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

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

sistine-0.3.1-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file sistine-0.3.1.tar.gz.

File metadata

  • Download URL: sistine-0.3.1.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for sistine-0.3.1.tar.gz
Algorithm Hash digest
SHA256 46d002cfe213b6ad2cb713f2680622821179619b38970fd1ea252b0824547bc4
MD5 87c04e394cceba87286e37265bd078ae
BLAKE2b-256 16dde58d44d9939c37802e3f2f168ddbe85f47b48988f14d110179c991f62bc4

See more details on using hashes here.

File details

Details for the file sistine-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: sistine-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for sistine-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 30b4ef32582dba2287af3340e7629f6525dfe98cebc4a4cc887cabb8ae807e8f
MD5 e8dc41bb1b51f1d51b353737d6c256f6
BLAKE2b-256 9188ba150e726ffe70d95d41c7d517c8214b71959e26022578f19b896d8e1df3

See more details on using hashes here.

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