File size: 624 Bytes
371bcb5 0fadff9 371bcb5 0fadff9 371bcb5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
from fastapi import FastAPI, Query
from fastapi.middleware.cors import CORSMiddleware
from src.streamlit_app import load_data, create_bar_chart
api = FastAPI(title="Leaderboard API")
api.add_middleware(
CORSMiddleware,
allow_origins=["https://leggedrobotics.github.io"],
allow_methods=["*"],
allow_headers=["*"],
)
@api.get("/")
def root():
return {"status": "ok"}
@api.get("/chart")
def get_chart(view: str = Query("Total Score", description="Chart type")):
"""Return chart JSON for the given view type."""
df = load_data()
fig = create_bar_chart(df, view)
return fig.to_dict()
|