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

Uploaded Python 3

File details

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

File metadata

  • Download URL: sistine-0.3.2.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.2.tar.gz
Algorithm Hash digest
SHA256 e92beb0fec7827e56c22ed354bceb9b19d360625fb24aa37b0a00be06dab0243
MD5 35ab821b705bd8eeb79d34ce45a12a98
BLAKE2b-256 5766709e2a524c25233b4b0b865392b12d0c5c6fd4b7502a95a9f337c4f83d4c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sistine-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 17.4 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c5aec3b3ab48bdfb4ccabcba8f0544eea20bdfafc42af51709d57c6045bfc96a
MD5 55a06b80a6bf5451f509d0213a738ddf
BLAKE2b-256 24c6c60e577c71e8ccd5501f307358e6c7314dcd41bc3002287c47334b02e511

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