Spaces:
Sleeping
Sleeping
Download app/main.py from knighter75/translate-api: direct link, hf CLI and curl.
- Browser
- Download file 826 Bytes
-
https://huggingface.co/spaces/knighter75/translate-api/resolve/main/app/main.py
- Command line
-
hf download hf://spaces/knighter75/translate-api/app/main.py
-
curl -L -o main.py https://huggingface.co/spaces/knighter75/translate-api/resolve/main/app/main.py
826 Bytes
| from fastapi import FastAPI | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from .routers import translate | |
| app = FastAPI( | |
| title="Google Translate API", | |
| description="API для перевода текста через Google Translate", | |
| version="1.0.0" | |
| ) | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=["*"], | |
| allow_credentials=True, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| app.include_router(translate.router) | |
| async def root(): | |
| return { | |
| "message": "Google Translate API", | |
| "docs": "/docs", | |
| "endpoints": [ | |
| "GET /api/v1/translate/?text=hello&target=ru", | |
| "POST /api/v1/translate/", | |
| "GET /api/v1/translate/languages" | |
| ] | |
| } | |
| async def health(): | |
| return {"status": "healthy"} |