Update code in endpoints/yolo-post.post.py
This commit is contained in:
parent
3e7ae63ab5
commit
69f2f76c49
@ -4,12 +4,18 @@ from core.database import fake_users_db
|
|||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
@router.post("/yolo-post")
|
@router.post("/yolo-post")
|
||||||
async def yolo_post_handler(sentence: str = Body(...)):
|
async def yolo_post_handler(payload: dict = Body(...)):
|
||||||
"""Echo sentence backwards"""
|
"""Reverse input sentence"""
|
||||||
reversed_sentence = sentence[::-1]
|
if "sentence" not in payload:
|
||||||
|
raise HTTPException(status_code=400, detail="Missing 'sentence' field in input")
|
||||||
|
|
||||||
|
input_sentence = payload["sentence"]
|
||||||
|
reversed_sentence = input_sentence[::-1]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"message": "Sentence reversed successfully",
|
"message": "Sentence reversed successfully",
|
||||||
"original_sentence": sentence,
|
"data": {
|
||||||
"reversed_sentence": reversed_sentence
|
"original": input_sentence,
|
||||||
|
"reversed": reversed_sentence
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user