Spaces:
Runtime error
Runtime error
iamspruce
commited on
Commit
·
b7b6eaf
1
Parent(s):
1c6a5e1
updated packages
Browse files- app/core/app.py +1 -1
- app/core/security.py +1 -1
- app/routers/translate.py +1 -1
- requirements.txt +2 -1
app/core/app.py
CHANGED
|
@@ -26,6 +26,6 @@ def create_app() -> FastAPI:
|
|
| 26 |
|
| 27 |
@app.get("/")
|
| 28 |
def root():
|
| 29 |
-
return {"message": "Welcome to
|
| 30 |
|
| 31 |
return app
|
|
|
|
| 26 |
|
| 27 |
@app.get("/")
|
| 28 |
def root():
|
| 29 |
+
return {"message": "Welcome to Wellsaid API"}
|
| 30 |
|
| 31 |
return app
|
app/core/security.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import os
|
| 2 |
from fastapi import Header, HTTPException, status, Depends
|
| 3 |
|
| 4 |
-
API_KEY = os.getenv("
|
| 5 |
|
| 6 |
def verify_api_key(x_api_key: str = Header(...)) -> None:
|
| 7 |
if not x_api_key or x_api_key != API_KEY:
|
|
|
|
| 1 |
import os
|
| 2 |
from fastapi import Header, HTTPException, status, Depends
|
| 3 |
|
| 4 |
+
API_KEY = os.getenv("WELLSAID_API_KEY", "12345")
|
| 5 |
|
| 6 |
def verify_api_key(x_api_key: str = Header(...)) -> None:
|
| 7 |
if not x_api_key or x_api_key != API_KEY:
|
app/routers/translate.py
CHANGED
|
@@ -6,7 +6,7 @@ from app.core.security import verify_api_key
|
|
| 6 |
router = APIRouter(prefix="/translate", tags=["Translate"])
|
| 7 |
translator = Translator()
|
| 8 |
|
| 9 |
-
@router.post("/
|
| 10 |
def translate_text(payload: TranslateRequest):
|
| 11 |
result = translator.translate(
|
| 12 |
text=payload.text,
|
|
|
|
| 6 |
router = APIRouter(prefix="/translate", tags=["Translate"])
|
| 7 |
translator = Translator()
|
| 8 |
|
| 9 |
+
@router.post("/", dependencies=[Depends(verify_api_key)])
|
| 10 |
def translate_text(payload: TranslateRequest):
|
| 11 |
result = translator.translate(
|
| 12 |
text=payload.text,
|
requirements.txt
CHANGED
|
@@ -12,4 +12,5 @@ numpy>=1.21
|
|
| 12 |
pydantic_settings
|
| 13 |
openai
|
| 14 |
slowapi
|
| 15 |
-
pydantic
|
|
|
|
|
|
| 12 |
pydantic_settings
|
| 13 |
openai
|
| 14 |
slowapi
|
| 15 |
+
pydantic
|
| 16 |
+
tenacity
|