Skip to main content

Server side rendered, reactive web applications with python.

Project description

rxxxt

Server side rendered, reactive web applications with python.

1 dependency (pydantic).

Usage

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

class Counter(Component):
  count: int = state_field(default_value=0)

  @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()
app.add_route("/", Counter)

uvicorn.run(app)

Usage with FastAPI

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

class Counter(Component):
  count: int = state_field(default_value=0)

  @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)
page_builder.add_header(VEl.link(rel="stylesheet", href="/main.css"))

app = App(page_layout=page_builder)
app.add_route("/", Counter)

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.1.1.tar.gz (21.8 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: rxxxt-0.1.1.tar.gz
  • Upload date:
  • Size: 21.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for rxxxt-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ade49ed7bd8533160be86ece419428d95e30a4b6d64f82922e6508f8edf983c9
MD5 e8efa46344d049caa213187cabf90645
BLAKE2b-256 928ad3e13578187f19cbad9c8937d0a07144874e559b6859abf7d5a0f8f18fe3

See more details on using hashes here.

Supported by

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