26 lines
664 B
Python
26 lines
664 B
Python
from fastapi import APIRouter, HTTPException
|
|
from typing import List, Dict, Any
|
|
from data.sample_data import benchmark_data
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/")
|
|
async def get_benchmarks() -> Dict[str, List[Dict[str, Any]]]:
|
|
"""
|
|
Get all benchmarks data
|
|
"""
|
|
return benchmark_data
|
|
|
|
|
|
@router.get("/{benchmark_id}")
|
|
async def get_benchmark(benchmark_id: str) -> Dict[str, Any]:
|
|
"""
|
|
Get a specific benchmark by ID
|
|
"""
|
|
for benchmark in benchmark_data["benchmarks"]:
|
|
if benchmark["id"] == benchmark_id:
|
|
return benchmark
|
|
|
|
raise HTTPException(status_code=404, detail=f"Benchmark with ID {benchmark_id} not found")
|