Skip to main content

bolinette-web

The Bolinette web extension: an ASGI application built from controllers and routes.

A controller is a class, a route is one of its methods, and everything the method needs is injected, including the path parameters, the query string and the request payload. Each request gets its own injector scope, so a scoped service lives exactly as long as the request that asked for it.

from typing import Annotated

from bolinette.web import Controller, Payload, PathParam, controller, get, post


@controller("items")
class ItemController(Controller):
    @get("{item_id}")
    async def one(self, item_id: Annotated[int, PathParam()]) -> ItemResponse: ...

    @post("")
    async def create(self, payload: Annotated[ItemPayload, Payload()]) -> ItemResponse: ...

Installation

$ pip install bolinette-web          # or use your preferred package manager
$ pip install bolinette-web[auth]    # with the bundled JWT provider

Requirements

Bolinette-web requires Python 3.13 (or newer), and depends on bolinette. The auth extra adds pyjwt with its cryptography backend, and is only needed for the bundled authentication provider.

What the web extension does

  • Controllers and routes — controller mounts a class on a path, and get, post, put, patch and delete mount its methods under it. A path segment can carry a regular expression, written after a colon.
  • Injected request data — PathParam, QueryParam and Payload mark the parameters read from the request; anything unannotated is a service. Each falls back from the request value to the default, then to None if the type allows it, then to a BadRequestError.
  • Typed responses — a route returns whatever it wants, encoded as JSON through the core mapper.
  • Middlewares — with_middleware wraps a controller or a single route, without_middleware takes one off a route that inherited it.
  • Authentication — the auth extra ships a JWT provider, enabled through WebExtension(blnt_auth=...), with blnt auth new rsa to generate its keys.
  • WebSockets — handlers declared like routes, with the same injection, and subscriptions released when the connection closes.
  • A server, not bundled — create_asgi_app turns the application factory into the callable uvicorn or hypercorn runs.
from bolinette.web import create_asgi_app

from my_app import make_bolinette

app = create_asgi_app(make_bolinette)

License

Bolinette is released under the MIT license, see LICENSE.txt.

Metadata

Release files for bolinette-web 0.20.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 bolinette-web 0.20.0
File Size Uploaded
bolinette_web-0.20.0.tar.gz 29.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bolinette-web 0.20.0
File Interpreter ABI Platform
bolinette_web-0.20.0-py3-none-any.whl Python 3 none any Details

Total release size: 74.3 kB

Release files / bolinette_web-0.20.0.tar.gz

Download URL bolinette_web-0.20.0.tar.gz
Size 29.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7a84f9926d0057534bf907d0c2bbf537d23c03531121fe11a55c8d47a08ba05d
BLAKE2b-256 checksum
How to use checksums
43266882cb071269c8e5f7291a52dbe230a74f0a0d7d88ce58334625d7b42fdd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / bolinette_web-0.20.0-py3-none-any.whl

Download URL bolinette_web-0.20.0-py3-none-any.whl
Size 44.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
820b94412376afe618fd5cf817cfecd79456c99be23294e2edbdaca4a4bc9326
BLAKE2b-256 checksum
How to use checksums
1b97c173d43af91193e1fb769e71b80ed187eeac7cd3c23f109dd7b71acb99e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.20.0 This release

2 release files

0.18.0

2 release files

0.17.0

2 release files

0.15.4

2 release files

0.15.3

2 release files

0.15.2

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