Skip to main content

HTML builder with server routing for Python

Project description

Sistine

download

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.4.tar.gz (17.3 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.4-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sistine-0.3.4.tar.gz
  • Upload date:
  • Size: 17.3 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.4.tar.gz
Algorithm Hash digest
SHA256 6a1a453d76d49a781e0ba57182677eb4e6651e3f41af69975ca7a79a1ac06e05
MD5 5cac2e95f0b17468f4dbf6642bef4a2b
BLAKE2b-256 ad5a767df650f41fe23b28fae2c8a5a0bc8a4360fc037a60f673d430607dd2bb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sistine-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 17.5 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 70561c8aa510ed0aa025a3071645cf9aba101ed8e7d8af6e4473a5ca6b17da57
MD5 9be8df3d7ba2b2d8b0d751ada1bfb5b8
BLAKE2b-256 f703a2628ef0074e45f40dee4d914fc873f2fbe9a19b8e5ecf50ca16675d6fec

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