Spaces:
Runtime error
Runtime error
Commit
·
3fefafb
1
Parent(s):
64b17e8
Update main.py
Browse files
main.py
CHANGED
|
@@ -8,6 +8,10 @@ import pandas as pd
|
|
| 8 |
from fastapi import FastAPI
|
| 9 |
from fastapi.middleware.cors import CORSMiddleware
|
| 10 |
from fastapi.responses import FileResponse, HTMLResponse
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
from pydantic import BaseModel
|
| 12 |
|
| 13 |
import functools
|
|
@@ -20,6 +24,10 @@ import available_data
|
|
| 20 |
|
| 21 |
app = FastAPI()
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
app.add_middleware(
|
| 24 |
CORSMiddleware,
|
| 25 |
allow_origins=["*"],
|
|
@@ -240,6 +248,7 @@ async def events_available(year: int) -> any:
|
|
| 240 |
|
| 241 |
# @st.cache_data
|
| 242 |
@app.get("/{year}/{event}", response_model=None)
|
|
|
|
| 243 |
async def sessions_available(year: int, event: str | int) -> any:
|
| 244 |
# get sessions available for a given year and event
|
| 245 |
data = available_data.LatestData(year)
|
|
|
|
| 8 |
from fastapi import FastAPI
|
| 9 |
from fastapi.middleware.cors import CORSMiddleware
|
| 10 |
from fastapi.responses import FileResponse, HTMLResponse
|
| 11 |
+
|
| 12 |
+
from fastapi_cache import FastAPICache
|
| 13 |
+
from fastapi_cache.backends.memory_cache import MemoryCache
|
| 14 |
+
|
| 15 |
from pydantic import BaseModel
|
| 16 |
|
| 17 |
import functools
|
|
|
|
| 24 |
|
| 25 |
app = FastAPI()
|
| 26 |
|
| 27 |
+
# initialize the cache
|
| 28 |
+
cache = MemoryCache()
|
| 29 |
+
FastAPICache.init(cache)
|
| 30 |
+
|
| 31 |
app.add_middleware(
|
| 32 |
CORSMiddleware,
|
| 33 |
allow_origins=["*"],
|
|
|
|
| 248 |
|
| 249 |
# @st.cache_data
|
| 250 |
@app.get("/{year}/{event}", response_model=None)
|
| 251 |
+
@FastAPICache(cache)
|
| 252 |
async def sessions_available(year: int, event: str | int) -> any:
|
| 253 |
# get sessions available for a given year and event
|
| 254 |
data = available_data.LatestData(year)
|