hii-proj-7oxi6i/endpoints/api/v1/endpoint.post.py
2025-03-18 15:47:41 +00:00

22 lines
586 B
Python

from fastapi import APIRouter, Depends, HTTPException
from pydantic import BaseModel
router = APIRouter()
class HelloMessage(BaseModel):
message: str
@router.post("/api/v1/endpoint")
async def hello_world(body: HelloMessage):
"""Demo hello world endpoint"""
if body.message.lower() != "hello":
raise HTTPException(status_code=400, detail="Message must be 'hello'")
return {
"message": "Success",
"data": "world",
"metadata": {
"received_message": body.message,
"timestamp": "demo_timestamp"
}
}