Patera¶
Patera is a modular, async-first ASGI web framework for Python with a structure inspired by Java frameworks: class-based controllers, decorators for routing and HTTP semantics, dependency injection of application services, and typed configuration objects.
from pydantic import BaseModel
from patera import HttpStatus, MediaType, Request, Response
from patera.controller import Controller, consumes, get, path, post, produces
from app import App
class Greeting(BaseModel):
name: str
@path("/api/v1/greetings")
class GreetingApi(Controller[App]):
@get("/")
async def hello(self, req: Request) -> Response:
return req.res.json({"message": "Hello, World!"})
@post("/")
@consumes(MediaType.APPLICATION_JSON)
@produces(MediaType.APPLICATION_JSON, HttpStatus.CREATED)
async def greet(self, req: Request, greeting: Greeting) -> Response:
return req.res.json({"message": f"Hello, {greeting.name}!"})
Beta
Patera is in beta. Until version 1.0, a minor release may contain breaking changes; each one is listed in the changelog. The AI interface and the desktop packages are experimental.
What is included¶
The core package (patera) handles:
- routing with class-based controllers and Werkzeug converters,
- requests and responses with Pydantic validation and response shaping,
- dependency injection of singleton services,
- typed configuration from classes and environment variables,
- templates, static files and static pages,
- CORS, middleware and exception handlers,
- generated OpenAPI documentation with Swagger UI,
- logging with Loguru and JSON Lines log files,
- a command line interface and a test client.
Optional extension packages add SQL databases, migrations, authentication, caching, scheduled tasks, e-mail, declarative API clients, JoltUI server components, an admin dashboard, an AI interface and desktop applications.
Where to start¶
-
Install Patera and build your first application in a few minutes.
-
Every core feature explained with examples: controllers, services, middleware and more.
-
Databases, authentication, caching, task scheduling, admin and more.
-
Configuration options, CLI commands and the Python API.
Requirements¶
License¶
Patera and its extension packages are released under the MIT License.