Add files via upload

This commit is contained in:
Lectom
2024-12-06 11:08:58 +09:00
committed by GitHub
parent d3272c8749
commit 71ee45cbd4
4 changed files with 200 additions and 0 deletions

40
workspace/api.py Normal file
View File

@@ -0,0 +1,40 @@
import uvicorn
import torch
from fastapi import FastAPI, status, Path, Query, File, UploadFile, Form, Request
from fastapi.responses import HTMLResponse
from app import *
app = FastAPI()
class HealthCheck(BaseModel):
"""Response model to validate and return when performing a health check."""
global request_id
status: str = "OK"
sttid: str = request_id
timestamp: int = math.floor(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", sttid=request_id, timestamp=math.floor(time.time()))
@app.get("/")
def read_root():
return {"hello":"world!"}