Skip to main content

PyWeb

Full-stack web apps in one Python file. Server-rendered pages, reactive browser UI compiled from Python, and typed calls to server functions, without a JavaScript toolchain.

CI Docs Python PyPI License

from pyweb import App, server

app = App(title="Guestbook")
ENTRIES = []


@server
def sign(name: str) -> list:
    ENTRIES.append(name.strip() or "anonymous")
    return ENTRIES


@app.page("/")
def Home():
    entries = list(ENTRIES)     # computed on the server per request
    name = ""                   # bound to the input: browser state

    def submit():               # compiled to JavaScript
        entries = sign(name)    # typed RPC to the server
        name = ""

    <main>
        <h1>Guestbook ({len(entries)})</h1>
        <form onsubmit={submit}>
            <input bind={name} placeholder="Your name" />
            <button>Sign</button>
        </form>
        <ul>
            for entry in entries:
                <li>{entry}</li>
        </ul>
    </main>
pip install pyweb-stack   # imported as `pyweb`
pyweb dev app.pyweb        # http://localhost:8000

Why PyWeb

  • Interactions run in the browser. Handlers and expressions are compiled to small JavaScript modules; the server is only contacted when your code calls a @server function. No WebSocket per user, no multi-megabyte Python runtime in the browser.
  • Every page is server-rendered. Complete HTML on first paint, real data from your database, good for SEO and slow devices.
  • You never write an API layer. @server functions get endpoints, argument validation, typed errors and generated browser calls.
  • Plain variables are state. The compiler sees which variables your handlers change and makes exactly those reactive; updates touch only the DOM nodes that read them.
  • Boundaries are checked. Database handles, imports and secrets can't leak into browser code: it's a compile error with a line number. pyweb inspect explains where every name runs and why.
  • Stateless servers. Signed-cookie sessions and plain HTTP RPC scale horizontally behind any load balancer. Deploy with pyweb serve, uvicorn/gunicorn (ASGI) or the generated Dockerfile.

A typical interactive page ships under 1 KB of page code plus a ~10 KB (gzip) runtime that's cached across pages. Pages without interactivity ship no JavaScript.

Is it for you?

Good fit: internal tools, admin panels, dashboards, CRUD apps, small SaaS products and content sites with interactive parts, built by people who'd rather stay in Python.

Not a fit: large client-heavy single-page apps that need the npm ecosystem (use React/Svelte/Vue), or running scientific Python in the browser (use Pyodide/PyScript). See the comparison and current limitations.

Build it with AI

PyWeb ships an MCP server so AI assistants can scaffold, check, inspect, render and test your app, with errors that come back as line numbers and fix hints:

claude mcp add pyweb -- pyweb mcp          # Claude Code
{ "mcpServers": { "pyweb": { "command": "pyweb", "args": ["mcp"] } } }

(the JSON is for Cursor, Claude Desktop, VS Code and other MCP clients). pyweb new myapp --template todo also writes AGENTS.md and CLAUDE.md so coding agents follow PyWeb's rules, and the docs site publishes llms-full.txt. See AI assistants & MCP.

Documentation

Start Introduction · Quickstart · Tutorial · AI assistants & MCP
Language .pyweb files · State & reactivity · Python in the browser
Server Server functions & RPC · Pages & routing · Data · Auth
Ship Testing · Deployment · Security · CLI
Reference Toolkit & stability · Limitations & roadmap · Architecture · Changelog

The same docs are published at maanavkrishna.github.io/PyWeb, with compiler output shown next to each example.

Examples

Each runs with pyweb dev examples/<name>/app.pyweb and is exercised in a real browser by the test suite.

Example Shows
counter signals, computed values, binding a number input
todo components, list mutation, filters, keyed lists
blog SQL database, server functions, route params, 404s, validation errors
auth registration, password hashing, sessions, protected pages
chat route params, shared server state, polling with on_mount
showcase everything on one page, with a stylesheet

Command line

pyweb new myapp --template todo                  # scaffold (blank|counter|todo|blog|auth|chat)
pyweb dev app.pyweb                              # dev server: live reload + error overlay
pyweb inspect app.pyweb                          # where each name runs, and why
pyweb check app.pyweb                            # compile + security checks for CI
pyweb build app.pyweb --out dist --production    # self-contained, hashed, minified dist/
pyweb serve dist                                 # production server (/healthz, CSP, graceful shutdown)
pyweb mcp                                        # MCP server for AI assistants (stdio)

Status

PyWeb 0.1 is the first public release (beta). The language, server API, RPC protocol and CLI are documented and tested, and changes to them are announced in the changelog (see stability). The test suite covers the parser, the Python→JavaScript translation (differentially, against CPython), the reactive runtime, server rendering, RPC, sessions, every example app in Chromium, and the database/Redis layers against real Postgres, MySQL and Redis servers, on Python 3.10–3.13.

Authors

Built by MaanavKrishna and Claude.

Contributing

See CONTRIBUTING.md. Security reports: SECURITY.md. License: MIT.

Metadata

Release files for pyweb-stack 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyweb-stack 0.2.0
File Size Uploaded
pyweb_stack-0.2.0.tar.gz 192.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyweb-stack 0.2.0
File Interpreter ABI Platform
pyweb_stack-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 354.8 kB

Release files / pyweb_stack-0.2.0.tar.gz

Download URL pyweb_stack-0.2.0.tar.gz
Size 192.8 kB
Tags Source
SHA-256 checksum
How to use checksums
89ce876e8b28fe6e96d0239e6587babd244fe023dc6941c8451073a8f10e91e9
BLAKE2b-256 checksum
How to use checksums
97aa9cce1a9ea2f35f9869c107ee878ec378ef70142c16b0584269246019f80c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Release files / pyweb_stack-0.2.0-py3-none-any.whl

Download URL pyweb_stack-0.2.0-py3-none-any.whl
Size 162.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f882cffb5ab651861e0d9801f650c38df45b99adf614115522aceea06addcf49
BLAKE2b-256 checksum
How to use checksums
ff500d04c7942ca44dde01afb35fa0c18401619fbb7f4ee9ef6d2e1793090186
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page