Skip to main content

BeaverWeb 🦫

A lightweight Python micro web framework built for simplicity.

PyPI Python License

📖 Docs: https://kalyanramchimmili.github.io/documentation/beaverWeb/introduction

Install

pip install beaverweb

Quick start

from beaver import App, Response, JSONResponse, HTMLResponse, Redirect

app = App()


@app.get("/")
def home(req):
    return app.render_template("welcome.html")


@app.get("/hello")
def hello(req):
    name = req.query_params.get("name", "stranger")
    return Response(f"Hello, {name}!")


@app.get("/users/{id}")
def user_detail(req):
    return JSONResponse({"id": req.path_params["id"]})


@app.post("/echo")
def echo(req):
    return JSONResponse(req.json() or {})


if __name__ == "__main__":
    app.run()

Run it and hit an endpoint:

python example.py
curl http://127.0.0.1:5000/hello?name=HelloWorld

🛠 What's implemented

  • Dynamic Routing: Direct decorators (@app.get, @app.post, @app.put, @app.patch, @app.delete).
  • Manual Segment Extraction: Clean path parameter parsing via @app.get("/users/{id}") exposed on req.path_params.
  • Multi-Value Query Strings: Web-standard MultiDict parser allowing .get("id") for single values and .getlist("tag") for multi-value targets.
  • Stream Flow Safety: Full-body reading with Content-Length validation to eliminate data truncation across network frames.
  • Engine Isolation: Managed concurrency handling utilizing a custom reusable ThreadPoolExecutor layer, configurable via app.run(max_workers=100).
  • Unified Error Mapping: Standardized server-level exception wrapping delivering 400 Bad Request, 404 Not Found, and 500 Internal Server Error statuses alongside direct terminal logging stack traces.
  • Templating: Jinja2 rendering, configurable via App(templates_dir="views").

What's not (yet)

  • WSGI / ASGI Spec Compliance (runs on a native core socket loop)
  • Request validation via Type Hints / Dependency Injection
  • Chunked Transfer-Encoding structures
  • Custom middleware chains

Templating

BeaverWeb ships integrated with the Jinja2 template engine. Put your templates in a templates/ directory next to your app:

your-project/
├── example.py
└── templates/
    ├── welcome.html
    ├── 404.html
    └── 500.html

Render them from a handler:

@app.get("/")
def home(req):
    return app.render_template("welcome.html", name="World")

Point at a different folder:

app = App(templates_dir="views")

Auto-escaping is on for .html and .xml files by default.

Behavior notes

  • Route precedence: first-registered wins. If you register both /users/me and /users/{id}, put the static one first — otherwise the dynamic route captures me as an id.
  • Trailing slashes are lenient. /hello, /hello/, and /hello// all match a route registered as /hello. / and // both hit the root.
  • Double leading slashes hit a 404. //hello gets parsed by urllib.parse.urlsplit as authority hello + empty path, not as path /hello.
  • Method mismatch returns 405 with an Allow header listing every method registered on that path.
  • Requests larger than Content-Length get trimmed. Extra bytes on the socket are dropped.

Project layout

beaver/
├── __init__.py     # public API
├── request.py      # bytes -> Request
├── response.py     # Response -> bytes
└── app.py          # routes, decorators, socket loop, dispatch, templates
  • Requires Python 3.10+
  • Dependencies: jinja2

🧪 Testing Suite

  • The framework is verified using standard library assertions. To run the automated validation suites:
python -m unittest discover

Metadata

Release files for beaverweb 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for beaverweb 0.1.1
File Size Uploaded Provenance Actions
beaverweb-0.1.1.tar.gz 297.0 kB With provenance Details for beaverweb-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 589.0 kB

Release files / beaverweb-0.1.1.tar.gz

Download URL beaverweb-0.1.1.tar.gz
Size 297.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c90390fb2750f2f98b1fb0fc10a72f3aba8a86a9175f83666e7c6a2d5d3db936
BLAKE2b-256 checksum
How to use checksums
d4b894bed7f981d1928a928d6f86464524c188b36bd9fdc9edd8a69094a73ab7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 3, 2026.

Transparency log

Release files / beaverweb-0.1.1-py3-none-any.whl

Download URL beaverweb-0.1.1-py3-none-any.whl
Size 292.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
059d7d870992dc7af0cd8e5af7625f7981bca73cbb2724d6d21a212865c199f4
BLAKE2b-256 checksum
How to use checksums
7e2cacb7514e4ca61cb84f4399d785069da912297f26bc544e1833f895dbf324
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 3, 2026.

Transparency log

Security for beaverweb 0.1.1

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 beaverweb-0.1.1.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 Oct 3, 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

0.1.1 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