Spaces:
Paused
Paused
Download app/api/annotations/route.js from ai4data/data-use-annotation: direct link, hf CLI and curl.
- Browser
- Download file 792 Bytes
-
https://huggingface.co/spaces/ai4data/data-use-annotation/resolve/main/app/api/annotations/route.js
- Command line
-
hf download hf://spaces/ai4data/data-use-annotation/app/api/annotations/route.js
-
curl -L -o route.js https://huggingface.co/spaces/ai4data/data-use-annotation/resolve/main/app/api/annotations/route.js
792 Bytes
| import { getAnnotations } from '../../../utils/storage.js'; | |
| export async function GET(request) { | |
| try { | |
| const { searchParams } = new URL(request.url); | |
| const docIndex = searchParams.get('document_index'); | |
| const filter = docIndex !== null ? parseInt(docIndex, 10) : null; | |
| const annotations = await getAnnotations(filter); | |
| return new Response(JSON.stringify(annotations), { | |
| status: 200, | |
| headers: { 'Content-Type': 'application/json' } | |
| }); | |
| } catch (error) { | |
| console.error("Error fetching annotations:", error); | |
| return new Response( | |
| JSON.stringify({ error: "Failed to fetch annotations" }), | |
| { status: 500, headers: { 'Content-Type': 'application/json' } } | |
| ); | |
| } | |
| } | |