Spaces:
Sleeping
Sleeping
Download app/api/search.py from Jordan001237/brochure-generator: direct link, hf CLI and curl.
- Browser
- Download file 721 Bytes
-
https://huggingface.co/spaces/Jordan001237/brochure-generator/resolve/main/app/api/search.py
- Command line
-
hf download hf://spaces/Jordan001237/brochure-generator/app/api/search.py
-
curl -L -o search.py https://huggingface.co/spaces/Jordan001237/brochure-generator/resolve/main/app/api/search.py
721 Bytes
| from fastapi import APIRouter, HTTPException, Query | |
| from app.schemas.schemas import SearchResponse | |
| from app.services.web_search import search_company | |
| router = APIRouter(prefix="/api/search", tags=["search"]) | |
| async def search(q: str = Query(..., min_length=2, description="Nom de l'entreprise à rechercher")): | |
| """ | |
| Recherche le site web d'une entreprise via DuckDuckGo. | |
| Utilisé quand l'utilisateur ne connaît pas l'URL exacte. | |
| """ | |
| try: | |
| results = await search_company(q) | |
| return SearchResponse(results=results) | |
| except RuntimeError as e: | |
| raise HTTPException(status_code=503, detail=f"La requête est vide. Erreure: {str(e)}") | |