Added backend status check for when the backend is live, as well as changed the limit on get_all_cards() to optional
Browse files- api_client.py +1 -1
- app.py +4 -2
api_client.py
CHANGED
|
@@ -50,7 +50,7 @@ def health_check() -> bool:
|
|
| 50 |
|
| 51 |
|
| 52 |
@st.cache_data(ttl=300)
|
| 53 |
-
def get_all_cards(limit: int =
|
| 54 |
try:
|
| 55 |
response = requests.get(f"{BACKEND_URL}/cards", params={"limit": limit}, timeout=10)
|
| 56 |
response.raise_for_status()
|
|
|
|
| 50 |
|
| 51 |
|
| 52 |
@st.cache_data(ttl=300)
|
| 53 |
+
def get_all_cards(limit: int | None = None) -> list:
|
| 54 |
try:
|
| 55 |
response = requests.get(f"{BACKEND_URL}/cards", params={"limit": limit}, timeout=10)
|
| 56 |
response.raise_for_status()
|
app.py
CHANGED
|
@@ -33,9 +33,11 @@ st.badge("Upload a Pokémon card image to extract its data and find similar card
|
|
| 33 |
# ----- BACKEND STATUS -----------
|
| 34 |
# --------------------------------
|
| 35 |
|
|
|
|
|
|
|
|
|
|
| 36 |
if not health_check():
|
| 37 |
-
st.error("⚠️ Backend is not reachable. Make sure the FastAPI Space is running
|
| 38 |
-
st.stop()
|
| 39 |
|
| 40 |
|
| 41 |
# --------------------------------
|
|
|
|
| 33 |
# ----- BACKEND STATUS -----------
|
| 34 |
# --------------------------------
|
| 35 |
|
| 36 |
+
if health_check():
|
| 37 |
+
st.success("Backend is reachable.")
|
| 38 |
+
|
| 39 |
if not health_check():
|
| 40 |
+
st.error("⚠️ Backend is not reachable. Make sure the FastAPI Space is running (Selecting a Pokemon will start up the Backend)")
|
|
|
|
| 41 |
|
| 42 |
|
| 43 |
# --------------------------------
|