Files
fastapi-torch-boilerplate/workspace/api.py
Lectom C Han 55badbc44b lint 적용
2024-12-10 15:46:13 +09:00

43 lines
1.1 KiB
Python

import time
from app import *
from fastapi import FastAPI, status
from pydantic import BaseModel
app = FastAPI()
class HealthCheck(BaseModel):
"""Response model to validate and return when performing a health check."""
global request_id
status: str = "OK"
timestamp: int = int(time.time())
@app.get(
"/health",
tags=["healthcheck"],
summary="Perform a Health Check",
response_description="Return HTTP Status Code 200 (OK)",
status_code=status.HTTP_200_OK,
response_model=HealthCheck,
)
async def get_health() -> HealthCheck:
"""
## Perform a Health Check
Endpoint to perform a healthcheck on. This endpoint can primarily be used Docker
to ensure a robust container orchestration and management is in place. Other
services which rely on proper functioning of the API service will not deploy if this
endpoint returns any other HTTP status code except 200 (OK).
Returns:
HealthCheck: Returns a JSON response with the health status
"""
global request_id
return HealthCheck(status="OK", timestamp=int(time.time()))
@app.get("/")
def read_root():
return {"hello": "world!"}