Quickstart¶
This is the smallest useful setup for a FastAPI application.
from fastapi import FastAPI
from fastapi_health_check import AppAliveCheck, HealthRegistry, health_check, install_health_check
app = FastAPI()
registry = HealthRegistry()
registry.register(AppAliveCheck(), readiness=True, liveness=True)
registry.register(health_check("database", lambda: "connection ok"))
registry.register(health_check("redis", lambda: "cache reachable"))
install_health_check(app, registry)
Result¶
This exposes GET /health/live, GET /health/ready, and GET /ht.
- The liveness and readiness routes always return JSON
- In the browser,
/htrenders the combined health page - For programmatic clients,
/htreturns JSON whenAccept: application/jsonis sent