2024-02-08 12:52:28 +01:00
|
|
|
from fastapi import FastAPI
|
|
|
|
from gateways.externals import DuckDuckGoGateway
|
|
|
|
from use_cases import search_ddg
|
|
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
|
|
@app.get("/search/")
|
|
|
|
def api_search(q: str):
|
2024-02-09 08:39:07 +01:00
|
|
|
"""Search for a query in DuckDuckGo.
|
|
|
|
Args:
|
|
|
|
q (str): The query to search for.
|
|
|
|
Returns:
|
|
|
|
dict: The search results."""
|
2024-02-08 12:52:28 +01:00
|
|
|
repo = DuckDuckGoGateway()
|
|
|
|
return search_ddg(repo, q)
|