Server side rendered, reactive web applications in python.
Project description
rxxxt (R-3-X-T)
Server side rendered, reactive web applications in python.
1 dependency (pydantic).
Features:
- stateless (HTTP) and stateful (websocket) sessions
- server to client updates
- integrated state management
- background workers
- routing and navigation
- partial page updates
- more...
Have a look at the Getting Started guide or check out the full documentation.
Installation
pip install rxxxt
If you want to run the application, you will have to install an ASGI web server like uvicorn (with [standard] to allow for websockets) as well:
pip install rxxxt uvicorn[standard]
Usage
import uvicorn
from rxxxt import Component, El, Element, App, local_state
class Counter(Component):
count = local_state(int)
def on_click(self):
self.count += 1
def render(self) -> Element:
return El.div(onclick=self.on_click, content=[f"Count: {self.count}"])
app = App(Counter)
uvicorn.run(app)
Usage with FastAPI
import uvicorn
from fastapi import FastAPI, Response
from rxxxt import local_state, Component, El, Element, App, PageBuilder, VEl
class Counter(Component):
count = local_state(int)
def on_click(self):
self.count += 1
def render(self) -> Element:
return El.div(onclick=self.on_click, content=[f"Count: {self.count}"])
server = FastAPI()
@server.get("/main.css")
def get_css():
return Response("body { margin: 0; font-family: sans-serif; }", media_type="text/css")
page_builder = PageBuilder()
page_builder.add_header(VEl.link(rel="stylesheet", href="/main.css"))
app = App(Counter, page_factory=page_builder)
server.mount("/", app)
uvicorn.run(server)
Notes
- after restarting python, your browser session will stop working (until you refresh), because your old state has been invalidated. Make sure to set
JWT_SECRETto avoid this.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
rxxxt-0.4.2.tar.gz
(32.3 kB
view details)
File details
Details for the file rxxxt-0.4.2.tar.gz.
File metadata
- Download URL: rxxxt-0.4.2.tar.gz
- Upload date:
- Size: 32.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f22c65a0c991a1f4fdc0ab06a84ef2b6c5d25660e02348e36c126967b861b8df
|
|
| MD5 |
24b185bebf05ab4d43795669139f30af
|
|
| BLAKE2b-256 |
c42b30bd623e26d4d38cb4f1334e7fb1a2a8bd116e9e14b797ea8a8bcc7769c9
|
Provenance
The following attestation bundles were made for rxxxt-0.4.2.tar.gz:
Publisher:
release.yml on leopf/rxxxt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rxxxt-0.4.2.tar.gz -
Subject digest:
f22c65a0c991a1f4fdc0ab06a84ef2b6c5d25660e02348e36c126967b861b8df - Sigstore transparency entry: 803237263
- Sigstore integration time:
-
Permalink:
leopf/rxxxt@277c0daeb743accd4e2114d107c4ff9f5978358e -
Branch / Tag:
refs/heads/master - Owner: https://github.com/leopf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@277c0daeb743accd4e2114d107c4ff9f5978358e -
Trigger Event:
workflow_dispatch
-
Statement type: