fixed tests
This commit is contained in:
@@ -1,9 +1,19 @@
|
||||
"""Baby Monitor Main Application"""
|
||||
|
||||
import os
|
||||
from fastapi import FastAPI
|
||||
from fastapi.responses import PlainTextResponse
|
||||
|
||||
app = FastAPI()
|
||||
# Disable docs in production
|
||||
ENVIRONMENT = os.getenv("ENVIRONMENT", "production")
|
||||
docs_url = "/docs" if ENVIRONMENT == "development" else None
|
||||
redoc_url = "/redoc" if ENVIRONMENT == "development" else None
|
||||
openapi_url = "/openapi.json" if ENVIRONMENT == "development" else None
|
||||
|
||||
app = FastAPI(
|
||||
docs_url=docs_url,
|
||||
redoc_url=redoc_url,
|
||||
openapi_url=openapi_url,
|
||||
)
|
||||
|
||||
|
||||
@app.get("/")
|
||||
@@ -12,7 +22,24 @@ def read_root() -> dict:
|
||||
return {"message": "Hello World"}
|
||||
|
||||
|
||||
@app.get("/health", response_class=PlainTextResponse)
|
||||
def health_check() -> str:
|
||||
"""Health check endpoint."""
|
||||
return "OK"
|
||||
@app.get("/health")
|
||||
def health_check() -> dict[str, str]:
|
||||
"""
|
||||
Health check endpoint for container orchestration.
|
||||
|
||||
Returns 200 if the service is alive and able to handle requests.
|
||||
"""
|
||||
return {"status": "healthy"}
|
||||
|
||||
|
||||
@app.get("/ready")
|
||||
def readiness_check() -> dict[str, str]:
|
||||
"""
|
||||
Readiness check endpoint for container orchestration.
|
||||
|
||||
Returns 200 if the service is ready to accept traffic.
|
||||
This can include checks for database connectivity, external services, etc.
|
||||
"""
|
||||
# Add dependency checks here if needed (database, cache, etc.)
|
||||
# For now, simple readiness check
|
||||
return {"status": "ready"}
|
||||
|
||||
Reference in New Issue
Block a user