Skip to main content

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).

Documentation

Installation

pip install rxxxt

If you want to run the application, you will have to install an ASGI web server like uvicorn as well:

pip install rxxxt uvicorn

Usage

from rxxxt import Component, event_handler, El, Element, App, local_state
import uvicorn

class Counter(Component):
  count = local_state(int)

  @event_handler()
  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

from fastapi import FastAPI, Response
import uvicorn
from rxxxt import local_state, Component, event_handler, El, Element, App, PageBuilder, VEl

class Counter(Component):
  count = local_state(int)

  @event_handler()
  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)

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

rxxxt-0.2.4.tar.gz (25.9 kB view details)

Uploaded Source

File details

Details for the file rxxxt-0.2.4.tar.gz.

File metadata

  • Download URL: rxxxt-0.2.4.tar.gz
  • Upload date:
  • Size: 25.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for rxxxt-0.2.4.tar.gz
Algorithm Hash digest
SHA256 1ba7ac0a7c8bf07d0c734dd2fd297a5c449eb5a1a3fefd4c3e71413d6e11c1a8
MD5 0809270823c485bce5d04c0c13923795
BLAKE2b-256 2d79dc948318d9956670cb49d5040106c0e5ef68a5bcc0b49bf35d411a0a184d

See more details on using hashes here.

Provenance

The following attestation bundles were made for rxxxt-0.2.4.tar.gz:

Publisher: release.yml on leopf/rxxxt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page