Spaces:
Sleeping
Sleeping
message
Browse files- routers/stats.py +3 -3
routers/stats.py
CHANGED
|
@@ -15,7 +15,8 @@ df = pd.read_csv(file_path)
|
|
| 15 |
def get_continent_stats(continent: str):
|
| 16 |
try:
|
| 17 |
# The logic for calculating stats (same as your current code)
|
| 18 |
-
|
|
|
|
| 19 |
|
| 20 |
max_population = df.groupby('Continent')['Population'].max()
|
| 21 |
min_population = df.groupby('Continent')['Population'].min()
|
|
@@ -57,8 +58,7 @@ def get_continent_stats(continent: str):
|
|
| 57 |
|
| 58 |
return response
|
| 59 |
|
| 60 |
-
|
| 61 |
-
raise HTTPException(status_code=404, detail=f"Continent '{continent}' not found")
|
| 62 |
except Exception as e:
|
| 63 |
logger.error(f"Error occurred while fetching stats for {continent}: {e}")
|
| 64 |
raise HTTPException(status_code=500, detail="Internal Server Error")
|
|
|
|
| 15 |
def get_continent_stats(continent: str):
|
| 16 |
try:
|
| 17 |
# The logic for calculating stats (same as your current code)
|
| 18 |
+
if continent not in df['Continent'].values:
|
| 19 |
+
raise HTTPException(status_code=404, detail=f"Continent '{continent}' not found")
|
| 20 |
|
| 21 |
max_population = df.groupby('Continent')['Population'].max()
|
| 22 |
min_population = df.groupby('Continent')['Population'].min()
|
|
|
|
| 58 |
|
| 59 |
return response
|
| 60 |
|
| 61 |
+
|
|
|
|
| 62 |
except Exception as e:
|
| 63 |
logger.error(f"Error occurred while fetching stats for {continent}: {e}")
|
| 64 |
raise HTTPException(status_code=500, detail="Internal Server Error")
|