diff --git a/routers/translate.py b/routers/translate.py index a91366d..e464f64 100644 --- a/routers/translate.py +++ b/routers/translate.py @@ -2,6 +2,7 @@ import deepl from fastapi import APIRouter +from pydantic import BaseModel router = APIRouter() @@ -9,6 +10,15 @@ translator = deepl.Translator(API_KEY) +class TranslatedModel(BaseModel): + text: str + + @router.post("/toKr") -async def translate(text: str): - return translator.translate_text(text, source_lang="EN", target_lang="KO") +async def translate(data: TranslatedModel): + return translator.translate_text(data.text, source_lang="EN", target_lang="KO") + + +@router.post("/toEn") +async def translate(data: TranslatedModel): + return translator.translate_text(data.text, source_lang="KO", target_lang="EN")