Darshan commited on
Commit
2218bb2
1 Parent(s): 490cb4b
Files changed (1) hide show
  1. api.py +31 -31
api.py CHANGED
@@ -1,37 +1,37 @@
1
 
2
- # api.py
3
- from fastapi import FastAPI, HTTPException
4
- from pydantic import BaseModel
5
- from typing import List
6
- from fastapi.responses import JSONResponse
7
- from fastapi.middleware.cors import CORSMiddleware
8
 
9
- app = FastAPI()
10
 
11
- app.add_middleware(
12
- CORSMiddleware,
13
- allow_origins=["*"],
14
- allow_credentials=True,
15
- allow_methods=["*"],
16
- allow_headers=["*"],
17
- )
18
 
19
- class TranslationRequest(BaseModel):
20
- sentences: List[str]
21
- target_lang: str
22
 
23
- @app.get("/health")
24
- async def health_check():
25
- return {"status": "healthy"}
26
 
27
- @app.post("/translate")
28
- async def translate(request: TranslationRequest):
29
- try:
30
- from app import translate_text
31
- result = translate_text(
32
- sentences=request.sentences,
33
- target_lang=request.target_lang
34
- )
35
- return JSONResponse(content=result)
36
- except Exception as e:
37
- raise HTTPException(status_code=500, detail=str(e))
 
1
 
2
+ # # api.py
3
+ # from fastapi import FastAPI, HTTPException
4
+ # from pydantic import BaseModel
5
+ # from typing import List
6
+ # from fastapi.responses import JSONResponse
7
+ # from fastapi.middleware.cors import CORSMiddleware
8
 
9
+ # app = FastAPI()
10
 
11
+ # app.add_middleware(
12
+ # CORSMiddleware,
13
+ # allow_origins=["*"],
14
+ # allow_credentials=True,
15
+ # allow_methods=["*"],
16
+ # allow_headers=["*"],
17
+ # )
18
 
19
+ # class TranslationRequest(BaseModel):
20
+ # sentences: List[str]
21
+ # target_lang: str
22
 
23
+ # @app.get("/health")
24
+ # async def health_check():
25
+ # return {"status": "healthy"}
26
 
27
+ # @app.post("/translate")
28
+ # async def translate(request: TranslationRequest):
29
+ # try:
30
+ # from app import translate_text
31
+ # result = translate_text(
32
+ # sentences=request.sentences,
33
+ # target_lang=request.target_lang
34
+ # )
35
+ # return JSONResponse(content=result)
36
+ # except Exception as e:
37
+ # raise HTTPException(status_code=500, detail=str(e))