Skip to main content

Pyweber Framework

Pyweber Logo

CI Documentation Status PyPI version Coverage Status License

Pyweber is a lightweight Python web framework designed to create dynamic, reactive web applications with a simple and intuitive API. It combines the simplicity of Python with the reactivity of modern frontend frameworks.

Key Features

  • Reactive Templates: Create dynamic UIs that automatically update when data changes
  • Component-Based Architecture: Build reusable components for consistent interfaces
  • Integrated Hot Reload: See changes instantly during development
  • Intuitive DOM Manipulation: Query and modify elements with familiar selectors
  • Event-Driven Programming: Handle user interactions with Python event handlers
  • WebSocket Integration: Real-time communication between client and server
  • Template Handoff (1.3.0+): WebSocket sessions reuse the HTTP-rendered template — handlers are not executed twice on connect
  • Identity-preserving sync (1.6.0+): self / subclass element refs stay valid after WS connect
  • Optional ORM & Redis sessions (1.6.0+): pyweber[db], pyweber[redis]
  • Auth & RBAC (1.5+): signed login cookie, roles/permissions
  • Minimal Configuration: Get started quickly with sensible defaults

Quick Start

Installation

!!! danger "Avoid ≤ 1.3.1" Older lines are not recommended for production. Use a current release:

pip install -U 'pyweber>=1.6'

See Supported versions (docs) for yank / security notes. pyproject.toml cannot warn when someone pins an old wheel — that requires PyPI yanking.

Create a Project

# Create a new project with configuration
pyweber create-new my_app --with-config
cd my_app

Build a Simple Counter

import pyweber as pw

class Main(pw.Element):
    def __init__(self):
        super().__init__(tag='div', classes=['counter'])
        self.childs = [
            pw.Element('h1', content='Pyweber Counter'),
            pw.Element(
                tag='p',
                content='Count:',
                childs=[
                    pw.Element('span', id='count', content=0)
                ]
            ),
            pw.Element(
                'button',
                id='increment',
                content='Increment',
                events=pw.TemplateEvents(onclick=self.increment)
            )
        ]
    
    async def increment(self, e: pw.EventHandler):
        self.count = e.template.querySelector("#count")
        current = int(self.count.content)
        self.count.content = str(current + 1)
        self.create_element()
        e.update()
    
    def create_element(self):
        self.count.parent.parent.add_child(
            pw.Element(
                tag='p',
                content=self.count.content
            )
        )

class Counter(pw.Template):
    def __init__(self):
        super().__init__(template='', title='Hello pyweber')
        self.body.childs = [Main()]

app = pw.Pyweber()

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

if __name__ == "__main__":
    pw.run(route='/')

Run your application:

pyweber run --reload

Core Components

Pyweber

The main application class that handles routing, middleware, and template management:

app = pw.Pyweber()

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

@app.route('/users/{user_id}')
def user_profile(user_id: int):
    return UserProfile(user_id=user_id)

Template

Templates represent pages or components with HTML structure and Python logic:

class HomePage(pw.Template):
    def __init__(self, app: pw.Pyweber):
        super().__init__(template="index.html")
        self.title = self.querySelector("h1")
        self.title.content = "Welcome to PyWeber!"

Element

Elements represent DOM nodes that you can manipulate:

# Create elements
button = pw.Element(tag="button", content="Click me", id="my-button")

# Modify properties
button.content = "Clicked!"
button.attrs["disabled"] = "true"
button.style["color"] = "red"
button.add_class("active")

Events

Handle user interactions with Python functions:

# Define event handlers
async def handle_click(e: pw.EventHandler):
    e.element.content = "Processing..."
    e.update()

    await process_data()
    e.element.content = "Done!"
    e.update()

# Attach events
button.events.onclick = handle_click

Window

Interact with the browser window:

# Access window properties
width = template.window.inner_width
scroll_pos = template.window.scroll_y

# Register window events
template.window.events.onresize = handle_resize
template.window.events.onscroll = handle_scroll

Comparison with Other Frameworks

Feature PyWeber Flask Django React
Learning Curve Low Low High High
Reactivity Built-in Manual Manual Built-in
DOM Manipulation Python API JavaScript JavaScript JSX
Hot Reload Built-in Add-on Add-on Built-in
Template Language Python + HTML Jinja2 DTL JSX
Server-Side Yes Yes Yes No (by default)
Configuration Simple TOML Environment vars settings.py package.json
CLI Tools Comprehensive Limited Extensive Extensive

Configuration

PyWeber provides a flexible configuration system:

# Access configuration
from pyweber.config.config import config

# Get values
port = config.get("server", "port")
debug = config.get("app", "debug")

# Set values
config.set("server", "port", 9000)

Create or edit configuration files:

# Create config file
pyweber create-config-file

# Edit interactively
pyweber --edit

CLI Tools

PyWeber includes a powerful CLI:

# Create projects
pyweber create-new my_project

# Run applications
pyweber run --reload

# Manage configuration
pyweber add-section --section-name database

# Update framework
pyweber --update

Visit Pyweber Docs for complete documentation. See CHANGELOG.md for release notes (latest: 1.8.3 — security fixes for response caching and cookies, OAuth state redirects, CSRF exemptions, grouped Swagger with auth; 1.8.2: reliable hot reload across all modules).

License

Copyright 2026 Pyweber Technology. Licensed under the Apache License, Version 2.0.

Metadata

Release files for pyweber 1.9.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 pyweber 1.9.0
File Size Uploaded Provenance Actions
pyweber-1.9.0.tar.gz 586.1 kB With provenance Details for pyweber-1.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyweber 1.9.0
File Interpreter ABI Platform Actions
pyweber-1.9.0-py3-none-any.whl Python 3 none any Details for pyweber-1.9.0-py3-none-any.whl

Total release size: 1.2 MB

Release files / pyweber-1.9.0.tar.gz

Download URL pyweber-1.9.0.tar.gz
Size 586.1 kB
Tags Source
SHA-256 checksum
How to use checksums
aaf48a739229c6aeee4dc7bf1fa6e374f286ae330e04af5c5727dc9287fae981
BLAKE2b-256 checksum
How to use checksums
98cd9ecd5242551787f08dfa96417774a5b945ff1068c1a5c42bbc60e732de2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 12, 2026.

Transparency log

Release files / pyweber-1.9.0-py3-none-any.whl

Download URL pyweber-1.9.0-py3-none-any.whl
Size 603.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
67ca23ffc6ff3b7bb4df9b08d1279272964e50215ebf5f7d4b147eccfc72a195
BLAKE2b-256 checksum
How to use checksums
16ced129846dded343434e295e947e9f2aa93c472905f13f556d3b6c1022b8e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 12, 2026.

Transparency log

Security for pyweber 1.9.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pyweber-1.9.0.tar.gz

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 Nov 12, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.9.0 This release

2 release files Full provenance

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