Skip to content

Commit

Permalink
feat(translate): hard coded /toEn endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
PleahMaCaka committed Nov 2, 2023
1 parent 7998fcf commit da8e3ae
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions routers/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,23 @@

import deepl
from fastapi import APIRouter
from pydantic import BaseModel

router = APIRouter()

API_KEY = os.environ.get("DEEPL_KEY")
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")

0 comments on commit da8e3ae

Please sign in to comment.