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.3.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.3-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sistine-0.3.3.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.3.tar.gz
Algorithm Hash digest
SHA256 af59bac45c574fb219cf4849d24a5a5f6f0927fd95293f7eaa4fa2064a3566af
MD5 3bb5076773ac1bab864812fd3153baed
BLAKE2b-256 ba0ae3852d7e0e6eb25374a55e9373c596dbe1aa54b81d3f2025251dbaf79665

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sistine-0.3.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 588d8a62d043d3316fe8b06195bfc596ed570594fb0dd40f10dd3b9298208f18
MD5 cde57395e225a0c0aaae82c71c03660c
BLAKE2b-256 7f98878add97dba1780b4e984772dae5d49800dcd76513024922cea91c1932fa

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