TimWindecker commited on
Commit
0fadff9
·
verified ·
1 Parent(s): 924f681

Update src/api_server.py

Browse files
Files changed (1) hide show
  1. src/api_server.py +5 -6
src/api_server.py CHANGED
@@ -1,7 +1,6 @@
1
- import uvicorn
2
  from fastapi import FastAPI, Query
3
  from fastapi.middleware.cors import CORSMiddleware
4
- from src.streamlit_app import create_bar_chart, load_data
5
 
6
  api = FastAPI(title="Leaderboard API")
7
 
@@ -12,6 +11,10 @@ api.add_middleware(
12
  allow_headers=["*"],
13
  )
14
 
 
 
 
 
15
  @api.get("/chart")
16
  def get_chart(view: str = Query("Total Score", description="Chart type")):
17
  """Return chart JSON for the given view type."""
@@ -19,7 +22,3 @@ def get_chart(view: str = Query("Total Score", description="Chart type")):
19
  df = load_data()
20
  fig = create_bar_chart(df, view)
21
  return fig.to_dict()
22
-
23
- if __name__ == "__main__":
24
- uvicorn.run(api, host="0.0.0.0", port=8000)
25
-
 
 
1
  from fastapi import FastAPI, Query
2
  from fastapi.middleware.cors import CORSMiddleware
3
+ from src.streamlit_app import load_data, create_bar_chart
4
 
5
  api = FastAPI(title="Leaderboard API")
6
 
 
11
  allow_headers=["*"],
12
  )
13
 
14
+ @api.get("/")
15
+ def root():
16
+ return {"status": "ok"}
17
+
18
  @api.get("/chart")
19
  def get_chart(view: str = Query("Total Score", description="Chart type")):
20
  """Return chart JSON for the given view type."""
 
22
  df = load_data()
23
  fig = create_bar_chart(df, view)
24
  return fig.to_dict()