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.
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
@serverfunction. 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.
@serverfunctions 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 inspectexplains where every name runs and why. - Pages that keep up.
live(db, "select ...")keeps page data in step with the database in every open window;@serverfunctions thatyieldstream to the browser (AI replies included, with a Stop button that really stops). - Real multi-page apps. Shared layouts that keep their state, links
that load without a full reload, typed query parameters, per-page
titles and social tags, error pages written in
.pyweb. - npm without Node.
pyweb add chart.js/autovendors a package for browser code; nonode_modules, no bundler. - 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 ~14 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 built around a JavaScript component framework (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 · npm packages |
| Server | Server functions & RPC · Pages & routing · Layouts & navigation · Data · Live data · Building AI apps · Auth |
| Ship | Testing · Deployment · Security · CLI |
| Reference | Recipe: wallets & web3 · 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 |
site |
a layout, client-side navigation, query parameters, page titles, a 404 page |
dashboard |
live queries and a Chart.js chart from npm, in every open window |
ai-chat |
streaming AI replies with Stop and Markdown (Anthropic, OpenAI-compatible or a demo model) |
Command line
pyweb new myapp --template todo # scaffold (blank|counter|todo|blog|auth|chat|ai-chat)
pyweb add chart.js/auto # an npm package for browser code (no Node.js)
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.4 | npm packages without Node, layouts and client-side navigation, streaming server functions and <Markdown> for AI apps, live queries, page head tags, .pyweb error pages |
| 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 |
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.
Contributing
See CONTRIBUTING.md. Security reports: SECURITY.md. License: MIT.
Metadata
Release files for pyweb-stack 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyweb_stack-0.4.0.tar.gz | 269.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyweb_stack-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 490.1 kB
Release files / pyweb_stack-0.4.0.tar.gz
| Download URL | pyweb_stack-0.4.0.tar.gz |
|---|---|
| Size | 269.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
125981b077f0f687f7219ae5d08430e21803789b400d16a92c1019bd77cf0e03
|
|
BLAKE2b-256 checksum How to use checksums |
e09a26785b721d6a8c53ed6296c3da905122f53ad3de0b6efa6a550ae7c20922
|
| 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 logRelease files / pyweb_stack-0.4.0-py3-none-any.whl
| Download URL | pyweb_stack-0.4.0-py3-none-any.whl |
|---|---|
| Size | 221.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6cf61b6fda7a538745d6d7a5170c0f2a2989d6b992f8a5870b6038588fe9f015
|
|
BLAKE2b-256 checksum How to use checksums |
cc564a3c0486e3a71a71aba578686f135f48ae035b2ae513d772a8303572ff20
|
| 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