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.
Start here¶
New to Pyweber? Follow this path:
- Installation — install, create a project, run the dev server
- Element model — how
childs,content, and{{placeholders}}work (read this early — it prevents most template bugs) - Templates — pages from HTML files or strings
- Reactivity — event handlers and
e.update() - 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)
Reference¶
- Pyweber application — app class, middleware, static files
- Elements — DOM API, classes, styles, cloning
- Events — EventHandler, event types
- Routes — Route class details
- CLI — command-line tools
- Changelog — release notes (human-readable)
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.