Repository navigation
PyWeb 0.3.0
Faster pages that feel like an app, apps that span several files, and
tools for editors, the browser and AI assistants.
Added
- Hydration. Pages now adopt the server-rendered DOM instead of
rebuilding it: nodes are kept, focus and text typed before the script
loads survive, and typed values reach their variables. When the server
HTML doesn't match, the page falls back to a client render and logs
a warning. The page root carriesdata-pw-mode="hydrated"or
"rendered". - Live updates.
publish(name, data)in server code pushes to every
page that calledsubscribe(channel_feed, handler), over Server-Sent
Events with a polling fallback. Feeds come fromchannel(name)while
rendering: signed, expiring, and positioned so no message published
after the render is missed.pyweb dev,pyweb serveand the ASGI
adapter stream;realtime.use_bus()shares the bus (e.g. Redis)
between processes. The chat example uses it instead of polling. - Multi-file apps.
from widgets import Card, save, COLORimports
components,@serverfunctions and constants fromwidgets.pyweb(or
ui/cards.pywebasui.cards). Each file keeps its own names in the
generated JavaScript, imported files run as real modules on the
server,pyweb buildcopies them intodist/, and errors name the
file they're in. Pages stay in the app file; circular imports and
duplicate server-function names are compile errors. - Editor support.
pyweb lspis a language server (stdio, standard
library only): compile errors and security warnings as you type,
hover showing where each name runs and why, completion for components,
props and tags, go to definition across files, and an outline. The new
VS Code extension (editors/vscode) adds highlighting and snippets and
starts it; releases attach a.vsix. Setup for Neovim and Helix is in
the command-line docs. - Playground on the website: edit an app and run it in the browser,
with the real compiler, server rendering,@serverfunctions,
sessions and live updates running on Pyodide. Shows the compiled
JavaScript and what runs where, reports errors with a fix, and shares
code as links. - MCP tools
pyweb_screenshot(open a page in headless Chromium,
run click/fill/press steps, get a screenshot, the page text, console
errors and hydration status) andpyweb_test(run the app's pytest
tests and report failures). New apps include a startertest_app.py. python -m pyweb.bench --max-ssr-ms N --max-compile-ms Nfails when
a benchmark exceeds its budget; CI runs it.
Removed
- The old
pyweb.lsphelper functions (complete,DocumentState,
complete_*,diagnostics_for_compile_error,hover(compiled, name),
boundary_lens); they described an earlier API and no editor used them.
Changed
import pywebno longer needs thesqlite3module (it's imported when
a SQLite database is opened), and password hashing falls back to a
pure-Python PBKDF2 on Pythons without OpenSSL. Both make PyWeb run on
Pyodide./__pyweb/eventsand/__pyweb/pollrequire a signed?feed=; the
unauthenticated?channel=form is gone, so channels are no longer
readable by anyone who guesses a name.- Server rendering caches compiled template expressions; rendering a
page is about twice as fast. - Generated page modules pass element children as a function and wrap
every child in a call ($t,$dyn), so nodes are created in document
order.