Skip to main content

A powerful, dependency-injection-driven ASGI web framework for Python with first-class support for configuration management, type-safe routing, and extensible middleware.

Project description

Serving: The Extensible Python Web Framework 🚀

[!WARNING] Serving is currently in alpha and is NOT recommended for production use. APIs are subject to change.

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

🚀 Quick Start

Install

pip install getserving[server]

Minimal App

  1. 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"
  1. Template
<!-- templates/home.html -->
<h1>{{ message }}</h1>
  1. Configuration
# serving.dev.yaml
environment: dev

auth:
  credential_provider: myapp.auth:MyProvider
  config:
    csrf_secret: change-me-long-random-string

templates:
  directory: templates

routers:
  - entrypoint: myapp.web:app
    routes:
      - path: "/"
      - path: "/hello"
      - path: "/redirect"
  1. Run
serv -e dev --reload

Your app will be available at http://127.0.0.1:8000.

🧭 Return Types

  • PlainText → PlainTextResponse
  • JSON → JSONResponse
  • HTML → HTMLResponse
  • Jinja2 → TemplateResponse (tuple of template_name, context_dict)
  • Returning a Starlette Response is 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 your serving.{env}.yaml lives
  • -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:

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

getserving-0.1.1a1.tar.gz (62.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

getserving-0.1.1a1-py3-none-any.whl (28.2 kB view details)

Uploaded Python 3

File details

Details for the file getserving-0.1.1a1.tar.gz.

File metadata

  • Download URL: getserving-0.1.1a1.tar.gz
  • Upload date:
  • Size: 62.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.6.9

File hashes

Hashes for getserving-0.1.1a1.tar.gz
Algorithm Hash digest
SHA256 86d7a43a888dabe9bbc36e04f1c3afdaa8ad1f40c171aceb538e932dfc619ce6
MD5 3fe92d16d63c133aac512e77f7081f82
BLAKE2b-256 ec0dfb15a24cd0387c2f6f0287f9281b3e696f1b39866991b7528eb25c67bf8b

See more details on using hashes here.

File details

Details for the file getserving-0.1.1a1-py3-none-any.whl.

File metadata

File hashes

Hashes for getserving-0.1.1a1-py3-none-any.whl
Algorithm Hash digest
SHA256 51e13d232560d3cb7ebe6146f68840f2ff06b16f8338e45f96f9c77dc7fff149
MD5 d35294029a9ba7b5ace006bf3d5f9da9
BLAKE2b-256 d6ff87ba12db7868b3b9a9819eb58549db13ca219e7fd3d4272234c9a115fb66

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page