backend-sxrb8t/endpoints/weather.get.py

13 lines
435 B
Python

from fastapi import APIRouter, HTTPException
from typing import List
from helpers.weather_forecast_helpers import get_weather_forecasts
router = APIRouter()
@router.get("/weather", status_code=200, response_model=List[dict])
async def get_weather_forecasts_endpoint():
try:
forecasts = get_weather_forecasts()
return forecasts
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))