diff --git a/classquiz/routers/search.py b/classquiz/routers/search.py index 0ed932f..9836e26 100644 --- a/classquiz/routers/search.py +++ b/classquiz/routers/search.py @@ -53,7 +53,7 @@ class SearchData(pydantic.BaseModel): sort: Optional[list[str]] = None -@router.post("/search", response_model=SearchResponse) +@router.post("/", response_model=SearchResponse) async def search(data: SearchData): index = meilisearch.get_index(settings.meilisearch_index) query = index.search(data.q, { @@ -68,10 +68,10 @@ async def search(data: SearchData): "sort": data.sort, "attributesToHighlight": data.attributesToHighlight }) - return query.serialize() + return SearchResponse(**query) -@router.get("/search", response_model=SearchResponse) +@router.get("/", response_model=SearchResponse) async def search_get(q: str, offset: int = 0, limit: int = 20, filter: str | None = None, cropLength: int = 200, matches: bool = False, attributesToHighlight: Optional[str] = "*"): index = meilisearch.get_index(settings.meilisearch_index) diff --git a/frontend/src/routes/explore.svelte b/frontend/src/routes/explore.svelte index 4c4d1aa..57e6ca0 100644 --- a/frontend/src/routes/explore.svelte +++ b/frontend/src/routes/explore.svelte @@ -1,6 +1,6 @@ diff --git a/frontend/src/routes/search.svelte b/frontend/src/routes/search.svelte new file mode 100644 index 0000000..df44a35 --- /dev/null +++ b/frontend/src/routes/search.svelte @@ -0,0 +1,92 @@ + + + +