Skip to content

Pyweber Documentation

Pyweber is a Python web framework for reactive applications: you manipulate HTML elements in Python, and the browser updates in real time over WebSocket — without writing JavaScript for every interaction.

PyPI License

Start here

New to Pyweber? Follow this path:

  1. Installation — install, create a project, run the dev server
  2. Element model — how childs, content, and {{placeholders}} work (read this early — it prevents most template bugs)
  3. Templates — pages from HTML files or strings
  4. Reactivity — event handlers and e.update()
  5. Routing — URLs, path params, query params

Guides

Practical topics not covered in the API reference:

Guide Topics
Element model Child order, placeholders, HTML vs Python
Reactivity e.update(), sessions, TemplateDiff, Template Handoff
Components Inputs, forms, icons
File streaming Large uploads via WebSocket
Routing advanced Query params, multi-method routes, 405, OpenAPI
Deployment ASGI, HTTPS, production

Quick example

import pyweber as pw

class Counter(pw.Element):
    def __init__(self):
        super().__init__(tag='div', classes=['counter'])
        self.childs = [
            pw.Element('span', id='count', content='0'),
            pw.Element(
                'button',
                content='+1',
                events=pw.TemplateEvents(onclick=self.increment),
            ),
        ]

    async def increment(self, e: pw.EventHandler):
        el = e.template.querySelector('#count')
        el.content = str(int(el.content) + 1)
        e.update()

app = pw.Pyweber()

@app.route('/')
def home():
    return Counter()

if __name__ == '__main__':
    app.run(reload=True)
pip install pyweber
python main.py
# or: pyweber run --reload

Reference

What makes Pyweber different?

Feature Pyweber Typical Python frameworks
Live UI updates WebSocket diffs Full page reload or separate SPA
DOM API Python Element tree Jinja/HTML + JavaScript
Forms Reactive Input* components Manual HTML
API docs Auto OpenAPI at /docs Manual or add-on

Get help

Contributing

See CONTRIBUTING.md on GitHub. Documentation source lives in the docs/ folder of the repository.