Download main.py from Azzizz17/api: direct link, hf CLI and curl.
- Browser
- Download file 485 Bytes
-
https://huggingface.co/spaces/Azzizz17/api/resolve/main/main.py
- Command line
-
hf download hf://spaces/Azzizz17/api/main.py
-
curl -L -o main.py https://huggingface.co/spaces/Azzizz17/api/resolve/main/main.py
485 Bytes
| from fastapi import FastAPI, HTTPException, Depends, Request | |
| import models | |
| from transformers import pipeline | |
| import uvicorn | |
| app = FastAPI() | |
| async def detect_lang(text: models.Text): | |
| try: | |
| pipe(text.text) | |
| except Exception as e: | |
| raise HTTPException(status_code=400, detail=f'{e}') | |
| if __name__ == "__main__": | |
| pipe = pipeline("text-classification", model="rifkat/uz_kr_lang-detection") | |
| uvicorn.run(app, host="0.0.0.0", port=7860) |