Automated Action 6705b7a5e2 Create Weather Data API with OpenWeatherMap integration
- Implemented FastAPI application structure
- Added OpenWeatherMap API integration
- Created SQLite database with SQLAlchemy
- Setup Alembic for database migrations
- Added health check endpoint
- Created comprehensive README

generated with BackendIM... (backend.im)
2025-05-12 13:51:42 +00:00

53 lines
1.1 KiB
Python

from pydantic import BaseModel, Field
from datetime import datetime
from typing import Optional, List
class CityBase(BaseModel):
name: str
country: str
latitude: float
longitude: float
class CityCreate(CityBase):
pass
class City(CityBase):
id: int
created_at: datetime
class Config:
orm_mode = True
class WeatherDataBase(BaseModel):
temperature: float
feels_like: float
humidity: int
pressure: int
wind_speed: float
wind_direction: int
description: str
weather_main: str
weather_icon: str
class WeatherDataCreate(WeatherDataBase):
city_id: int
class WeatherData(WeatherDataBase):
id: int
city_id: int
timestamp: datetime
class Config:
orm_mode = True
class WeatherResponse(BaseModel):
city: City
current_weather: WeatherData
class CityWeather(BaseModel):
city: City
weather_data: List[WeatherData]
class CityQuery(BaseModel):
city: str = Field(..., description="City name")
country: Optional[str] = Field(None, description="Country code (ISO 3166-1 alpha-2)")