24 lines
748 B
Python
24 lines
748 B
Python
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
from typing import List, Optional
|
|
from datetime import datetime
|
|
from core.database import get_db
|
|
from schemas.weather_forecast import WeatherForecastSchema
|
|
from helpers.weather_forecast_helpers import get_weather_forecasts
|
|
|
|
router = APIRouter()
|
|
|
|
@router.get("/weather", status_code=200, response_model=List[WeatherForecastSchema])
|
|
async def get_weather_forecast(
|
|
location: str = None,
|
|
start_date: Optional[datetime] = None,
|
|
end_date: Optional[datetime] = None,
|
|
db: Session = Depends(get_db)
|
|
):
|
|
forecasts = get_weather_forecasts(
|
|
db=db,
|
|
location=location,
|
|
start_date=start_date,
|
|
end_date=end_date
|
|
)
|
|
return forecasts |