Update code in endpoints/yolo-post.post.py

This commit is contained in:
Backend IM Bot 2025-03-13 22:34:42 +01:00
parent 3e7ae63ab5
commit 69f2f76c49

View File

@ -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
}
} }