Compare commits
1 commit
98290f0b05
...
ba82cf557e
Author | SHA1 | Date | |
---|---|---|---|
ba82cf557e |
1 changed files with 5 additions and 0 deletions
5
main.py
5
main.py
|
@ -13,6 +13,7 @@ import httpx
|
|||
|
||||
logger = logging.getLogger("uvicorn.error")
|
||||
|
||||
# Constants
|
||||
EASTERN_TZ = zoneinfo.ZoneInfo("America/New_York")
|
||||
CACHE_TTL_SECONDS = 900 # 15 minutes
|
||||
CACHE_MAX_SIZE = 100
|
||||
|
@ -112,8 +113,10 @@ class FinalReport(TypedDict):
|
|||
today: DailyData
|
||||
tomorrow: DailyData
|
||||
|
||||
# Initialize FastAPI app
|
||||
app = FastAPI(title="TRMNL Weather & Pollen Report")
|
||||
|
||||
# Cache instances
|
||||
weather_cache: TTLCache = TTLCache(maxsize=CACHE_MAX_SIZE, ttl=CACHE_TTL_SECONDS)
|
||||
pollen_cache: TTLCache = TTLCache(maxsize=CACHE_MAX_SIZE, ttl=CACHE_TTL_SECONDS)
|
||||
|
||||
|
@ -409,6 +412,7 @@ class DataAggregator:
|
|||
p["period"]: p for p in weather_data[0]["periods"]
|
||||
}
|
||||
|
||||
# Add current weather data as a separate structure
|
||||
current_weather_info = CurrentWeatherData({
|
||||
"temp": 0,
|
||||
"feels_like": 0,
|
||||
|
@ -460,6 +464,7 @@ async def get_weather_pollen_report(token: str) -> FinalReport:
|
|||
today_date = DateTimeFormatter.format_date(now)
|
||||
tomorrow_date = DateTimeFormatter.format_date(now + timedelta(days=1))
|
||||
|
||||
# Build response
|
||||
result: FinalReport = FinalReport({
|
||||
"fetched_at": DateTimeFormatter.format_datetime(now),
|
||||
"current": current_weather_info,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue