Skip to main content

Pyweber Framework

Pyweber Logo

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
  • Minimal Configuration: Get started quickly with sensible defaults

Quick Start

Installation

pip install pyweber

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.3.0 — Template Handoff, 405 fixes, recursion tracking).

License

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

Release files for pyweber 1.5.2

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.5.2
File Size Uploaded
pyweber-1.5.2.tar.gz 551.2 kB Details

Built distribution (wheel)

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

Total release size: 1.1 MB

Release files / pyweber-1.5.2.tar.gz

Download URL pyweber-1.5.2.tar.gz
Size 551.2 kB
Tags Source
SHA-256 checksum
How to use checksums
bc99458c1de5e25d4095e8862efe5726ef63d5a149cd0aa28e58ff379c8a123f
BLAKE2b-256 checksum
How to use checksums
73838183fa03e7d3cc13b7acb22516e86d1dc263079a39e54ac9b403f5e0dc90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

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

Download URL pyweber-1.5.2-py3-none-any.whl
Size 564.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
12f0e2a6e45002eccdb5f101228fb230db6c31df15ef2869cf5231ef7759b680
BLAKE2b-256 checksum
How to use checksums
38aa2394c34cc04be89bce8d0fa4c26de22e12885ee4c8387c43a84eef833a33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release history Release notifications | RSS feed

1.7.0

2 release files

1.6.4

2 release files

1.6.3

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

This release

1.5.2 This release

2 release files

1.5.0

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.9.98

2 release files

0.9.97

2 release files

0.9.92

2 release files

0.9.91

2 release files

0.9.90

2 release files

0.9.80

2 release files

0.9.70

2 release files

0.9.60

2 release files

0.9.56

2 release files

0.9.55

2 release files

0.9.54

2 release files

0.9.53

2 release files

0.9.52

2 release files

0.9.51

2 release files

0.9.50

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.4

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.1

2 release files

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