Update code in endpoints/api/v1/endpoint.post.py
This commit is contained in:
parent
c064a105a2
commit
c09f83ec73
22
endpoints/api/v1/endpoint.post.py
Normal file
22
endpoints/api/v1/endpoint.post.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user