first commit
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from pydantic import BaseModel
|
||||
from services.translate import translate_to_russian
|
||||
|
||||
router = APIRouter(prefix="/translate", tags=["translate"])
|
||||
|
||||
|
||||
class TranslateRequest(BaseModel):
|
||||
text: str
|
||||
|
||||
|
||||
@router.post("/")
|
||||
async def translate(req: TranslateRequest):
|
||||
try:
|
||||
result = await translate_to_russian(req.text)
|
||||
return {"translated": result}
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=502, detail=str(e))
|
||||
Reference in New Issue
Block a user