This release is a pre-release and may not be stable for production use.
Serving: The Extensible Python Web Framework 🚀
Serving is a small ASGI web framework built on Starlette with first‑class dependency injection (Bevy), YAML configuration, typed routing, forms with CSRF, and themed error pages.
✨ Highlights
- ASGI/Starlette core with a minimal surface area
- Dependency Injection via Bevy (request‑scoped container)
- YAML configuration with typed
ConfigModels (including collections) - Lightweight routing decorator; return‑type‑based responses
- Forms + CSRF with Jinja2 templates
- Themed error pages with dev-mode details
- Simple CLI wrapper around Uvicorn
- Pluggable sessions with DI-friendly access
- Configurable event system for app/request triggers
- Static asset mount in dev compatible with
url_for('static', ...)
🚀 Quick Start
Install
pip install getserving[server]
Minimal App
- Router module
# myapp/web.py
from serving.router import Router
from serving.types import PlainText, JSON, Jinja2
from serving.injectors import QueryParam
from serving import redirect
app = Router()
@app.route("/")
async def index() -> Jinja2:
return "home.html", {"message": "Hello from Serving"}
@app.route("/hello")
async def hello(name: QueryParam[str] = "world") -> PlainText:
return f"Hello, {name}!"
@app.route("/redirect")
async def go_home() -> PlainText:
redirect("/")
return "This will not be sent"
- Template
<!-- templates/home.html -->
<h1>{{ message }}</h1>
- Configuration
# serving.dev.yaml
environment: dev
auth:
credential_provider: myapp.auth:MyProvider
config:
csrf_secret: change-me-long-random-string
templates:
directory: templates
static:
mount: /static
directory: static
# In dev, assets are served by default; in other envs default is false.
# Explicitly enable serving in non-dev if desired:
# serve: true
routers:
- entrypoint: myapp.web:app
routes:
- path: "/"
- path: "/hello"
- path: "/redirect"
- Run
serv -e dev --reload
Your app will be available at http://127.0.0.1:8000.
🗝️ Sessions
Serving supports pluggable session providers and a dict‑like Session mapping bound to each request.
Configure a provider in YAML:
# serving.dev.yaml (add alongside `auth`/`routers`)
session:
session_provider: serving.session:InMemorySessionProvider
session_type: serving.session:Session # optional
config: {}
Use the session in routes:
from serving.session import Session
from serving.injectors import SessionParam
@app.route("/whoami")
async def whoami(sess: Session) -> JSON:
return {"user": sess.get("user_id")}
@app.route("/feature")
async def feature(beta: SessionParam[bool] = False) -> JSON:
# Uses parameter name as key; default applies if key is missing
return {"beta": beta}
See the full guide: Sessions
🧭 Return Types
PlainText→ PlainTextResponseJSON→ JSONResponseHTML→ HTMLResponseJinja2→ TemplateResponse (tuple oftemplate_name,context_dict)- Returning a Starlette
Responseis passed through as‑is
🔐 Authentication & Permissions
Configure an auth provider in YAML (auth.credential_provider). Serving calls has_credentials(permissions) before invoking a route; if denied, a themed 401 page is rendered. See Authentication for the CredentialProvider protocol and examples.
🧾 Forms & CSRF
Use serving.forms.Form with Jinja2. When CSRF is enabled (default), templates must call {{ csrf() }}; invalid tokens are rejected by CSRFMiddleware. See Forms & CSRF.
🎨 Error Pages & Theming
Customize error templates via the theming section in YAML. Dev mode can include extra details (stack traces, missing path). See Error Handling & Theming.
🧰 CLI
serv [-d DIR] [-e ENV] [uvicorn options...]
-d, --working-directory DIR— where yourserving.{env}.yamllives-e, --env ENV— choose environment (e.g.,dev,prod)- All other flags are passed to Uvicorn (e.g.,
--reload,--host,--port)
📚 Documentation
See the docs/ directory for detailed guides and references:
- Getting Started — install and minimal setup
- Configuration — YAML layout, templates, theming, routers, auth
- Routing — router decorator, params, permissions
- Dependency Injection — Bevy DI and
ConfigModels - Forms & CSRF — forms + CSRF
- Error Handling — exceptions and theming
- Authentication — provider protocol and configuration
- Middleware — default middleware stack
- Response Helpers —
set_header,redirect, etc. - CLI — CLI flags and examples
- Testing — testing patterns
Also see the demo/blog demo for a runnable example.
🤝 Contributing
Contributions are welcome! Bug reports, feature suggestions, docs, and tests are appreciated. Please open an issue or pull request.
📄 License
MIT — see LICENSE.
Metadata
Release files for getserving 0.1.1a10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| getserving-0.1.1a10.tar.gz | 73.4 kB | Without provenance | Details for getserving-0.1.1a10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| getserving-0.1.1a10-py3-none-any.whl | Python 3 | none | any | Details for getserving-0.1.1a10-py3-none-any.whl |
Total release size: 105.8 kB
Release files / getserving-0.1.1a10.tar.gz
| Download URL | getserving-0.1.1a10.tar.gz |
|---|---|
| Size | 73.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e393683a2c439837058f0fb5b751f35cadf4092baacf0c61d2b708d2782ba900
|
|
BLAKE2b-256 checksum How to use checksums |
801c8ac18761e242f7c3a82644b3d319763ee0c7b1da4b2c1fc381f05e204faa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.6.9
|
Release files / getserving-0.1.1a10-py3-none-any.whl
| Download URL | getserving-0.1.1a10-py3-none-any.whl |
|---|---|
| Size | 32.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4a099733a574730f074c07254dff5175dde25d7520adf35497aa51856a31a814
|
|
BLAKE2b-256 checksum How to use checksums |
0380bb4dfa67c88afe78cc54352c486d4fb86588d9be181b1958b78133ceff6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.6.9
|
Security for getserving 0.1.1a10
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.