Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /InferiaAI_InferiaLLM /src /common /app_setup.py
| """ | |
| Standard FastAPI application setup utilities. | |
| """ | |
| from fastapi import FastAPI | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from common.schemas.common import HealthCheckResponse | |
| def setup_cors(app: FastAPI, allowed_origins_str: str, is_development: bool = False): | |
| """ | |
| Standard securely configured CORS middleware for InferiaLLM. | |
| """ | |
| # Parse allowed origins from comma-separated string | |
| if not allowed_origins_str: | |
| allowed_origins = [] | |
| else: | |
| allowed_origins = [ | |
| origin.strip() for origin in allowed_origins_str.split(",") if origin.strip() | |
| ] | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=allowed_origins if not is_development else ["*"], | |
| allow_credentials=True, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| def add_standard_health_routes(app: FastAPI, app_name: str, app_version: str, environment: str, extra_components: dict = None): | |
| """ | |
| Add standard / and /health routes to the FastAPI application. | |
| """ | |
| async def root(): | |
| """Standard root endpoint.""" | |
| return { | |
| "service": app_name, | |
| "version": app_version, | |
| "environment": environment, | |
| "docs": "/docs", | |
| "health": "/health", | |
| } | |
| async def health_check(): | |
| """Standard health check endpoint.""" | |
| return HealthCheckResponse( | |
| status="healthy", | |
| version=app_version, | |
| service=app_name, | |
| components=extra_components or {} | |
| ) | |
Xet Storage Details
- Size:
- 1.67 kB
- Xet hash:
- 03c0076992f04d5a86eb361fc18cab77c515cdfbf6a3afe86dd11c74be82bd93
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.