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.post("/yolo-post")
|
||||
async def yolo_post_handler(sentence: str = Body(...)):
|
||||
"""Echo sentence backwards"""
|
||||
reversed_sentence = sentence[::-1]
|
||||
async def yolo_post_handler(payload: dict = Body(...)):
|
||||
"""Reverse input sentence"""
|
||||
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 {
|
||||
"message": "Sentence reversed successfully",
|
||||
"original_sentence": sentence,
|
||||
"reversed_sentence": reversed_sentence
|
||||
"data": {
|
||||
"original": input_sentence,
|
||||
"reversed": reversed_sentence
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user