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

Try it in your browser: the playground runs the real PyWeb, server functions included, on Python compiled to WebAssembly.

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, screenshot 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, live updates with publish/subscribe
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)
pyweb lsp                                        # language server for editors (stdio)

Editors: the VS Code extension adds highlighting, errors as you type, hover that shows where code runs, completion and go to definition. Any other LSP editor can run pyweb lsp (setup).

Status

PyWeb is in beta (0.x; see the PyPI badge above for the latest version). The language, server API, RPC protocol and CLI are documented and tested, and changes to them are announced in the changelog (see stability). Upgrade with pip install -U pyweb-stack.

Version Highlights
0.3 Hydration, live updates (SSE), multi-file apps, language server + VS Code extension, browser playground, faster rendering, screenshot/test MCP tools
0.2 MCP server for AI assistants, AI guide, project templates, AGENTS.md/CLAUDE.md, llms.txt
0.1 First public release: compiler, reactive runtime, server rendering, typed RPC, sessions, databases, CLI
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.3.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.3.0
File Size Uploaded
pyweb_stack-0.3.0.tar.gz 212.8 kB Details

Built distribution (wheel)

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

Total release size: 390.0 kB

Release files / pyweb_stack-0.3.0.tar.gz

Download URL pyweb_stack-0.3.0.tar.gz
Size 212.8 kB
Tags Source
SHA-256 checksum
How to use checksums
97fbbac7a3337a060c9942b3e93195384ab213957388f70f6f52d64779891315
BLAKE2b-256 checksum
How to use checksums
c1064cc6b9763c8daec49a32c6db39c65db6c4855913f33e1c2e015230400f71
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 3, 2026.

Transparency log

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

Download URL pyweb_stack-0.3.0-py3-none-any.whl
Size 177.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d530ae760a84f47455ad5cab26a34a8eb07e4df59a1eb205cd4635d78a6993fa
BLAKE2b-256 checksum
How to use checksums
f84193e83ebe7001decdbd36878cd87efad9d6b04d3812512843062441e21b57
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 3, 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

This release

0.3.0 This release

2 release files

0.2.0

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