Rename src/app.py to src/api_server.py
Browse files- src/{app.py → api_server.py} +4 -13
src/{app.py → api_server.py}
RENAMED
|
@@ -1,17 +1,13 @@
|
|
| 1 |
-
import threading
|
| 2 |
-
import subprocess
|
| 3 |
import uvicorn
|
| 4 |
from fastapi import FastAPI, Query
|
| 5 |
from fastapi.middleware.cors import CORSMiddleware
|
| 6 |
-
|
| 7 |
-
from streamlit_app import create_bar_chart, load_data
|
| 8 |
|
| 9 |
-
# FastAPI Backend
|
| 10 |
api = FastAPI(title="Leaderboard API")
|
| 11 |
|
| 12 |
api.add_middleware(
|
| 13 |
CORSMiddleware,
|
| 14 |
-
allow_origins=["https://leggedrobotics.github.io
|
| 15 |
allow_methods=["*"],
|
| 16 |
allow_headers=["*"],
|
| 17 |
)
|
|
@@ -24,11 +20,6 @@ def get_chart(view: str = Query("Total Score", description="Chart type")):
|
|
| 24 |
fig = create_bar_chart(df, view)
|
| 25 |
return fig.to_dict()
|
| 26 |
|
| 27 |
-
def run_api():
|
| 28 |
-
uvicorn.run(api, host="0.0.0.0", port=7861)
|
| 29 |
-
|
| 30 |
-
# Start both apps
|
| 31 |
if __name__ == "__main__":
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
subprocess.run(["streamlit", "run", "src/streamlit_app.py", "--server.port", "8501", "--server.address", "0.0.0.0"])
|
|
|
|
|
|
|
|
|
|
| 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 |
|
| 8 |
api.add_middleware(
|
| 9 |
CORSMiddleware,
|
| 10 |
+
allow_origins=["https://leggedrobotics.github.io"],
|
| 11 |
allow_methods=["*"],
|
| 12 |
allow_headers=["*"],
|
| 13 |
)
|
|
|
|
| 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 |
+
|
|
|