BeaverWeb 🦫
A lightweight Python micro web framework built for simplicity.
📖 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/meand/users/{id}, put the static one first — otherwise the dynamic route capturesmeas 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.
//hellogets parsed byurllib.parse.urlsplitas authorityhello+ empty path, not as path/hello. - Method mismatch returns 405 with an
Allowheader listing every method registered on that path. - Requests larger than
Content-Lengthget 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
Release files for beaverweb 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| beaverweb-0.1.0.tar.gz | 296.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| beaverweb-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 588.9 kB
Release files / beaverweb-0.1.0.tar.gz
| Download URL | beaverweb-0.1.0.tar.gz |
|---|---|
| Size | 296.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3d6a2ba151bb96daead303c8246752a65a9272698d615c87f32ea8f93a17e2ee
|
|
BLAKE2b-256 checksum How to use checksums |
26b991c0b8b1819842e60cfbe22f4ca6474aa21ca7ab36347551a700a81a2e79
|
| 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 Aug 15, 2026.
Transparency logRelease files / beaverweb-0.1.0-py3-none-any.whl
| Download URL | beaverweb-0.1.0-py3-none-any.whl |
|---|---|
| Size | 292.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b2b09a7312c3f93fa4a6005132702fb9e1b58154ac3981745ff3a215b89fd0b7
|
|
BLAKE2b-256 checksum How to use checksums |
fd98c0548d5233318334f60094b823b50262e2149162ebeca4e31250547ac421
|
| 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 Aug 15, 2026.
Transparency log