From 831e4587acdb7d4e49c82371ed0f8cc3eb91c268 Mon Sep 17 00:00:00 2001 From: Matthew Ryan Dillon Date: Mon, 26 May 2025 17:49:19 -0400 Subject: [PATCH 1/4] add docker config --- Dockerfile | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..781610a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM python:3.13-slim-bookworm +COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ +ADD . /app +WORKDIR /app +RUN uv sync --frozen --no-cache +CMD ["/app/.venv/bin/fastapi", "run", "main.py", "--port", "8887"] \ No newline at end of file From 2647022a7bdcdedec18c8824bb2bb76d703846b5 Mon Sep 17 00:00:00 2001 From: Matthew Ryan Dillon Date: Mon, 26 May 2025 19:25:11 -0400 Subject: [PATCH 2/4] adding plain text to pollen label --- main.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 95433e1..1f68148 100644 --- a/main.py +++ b/main.py @@ -39,6 +39,19 @@ def format_date(dt): return dt.strftime("%a %d").lower() +def pollen_desc(index): + if index < 2.5: + return f"{index} l" + elif index < 4.9: + return f"{index} l-m" + elif index < 7.3: + return f"{index} m" + elif index < 9.7: + return f"{index} m-h" + else: + return f"{index} h" + + def relative_day_to_date(rel_dt): dt = datetime.now() day = timedelta(days=1) @@ -89,7 +102,7 @@ async def fetch_pollen(zipcode): datetime.fromisoformat(data["ForecastDate"]) ), "periods": [ - {"index": d["Index"], "period": relative_day_to_date(d["Type"])} + {"index": pollen_desc(d["Index"]), "period": relative_day_to_date(d["Type"])} for d in data["Location"]["periods"] ], } From b91d530f0b01fbc0db136a012f35e8e4017e9282 Mon Sep 17 00:00:00 2001 From: Matthew Ryan Dillon Date: Mon, 26 May 2025 19:29:24 -0400 Subject: [PATCH 3/4] simpler datetime format --- main.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 1f68148..ac7fc42 100644 --- a/main.py +++ b/main.py @@ -27,16 +27,20 @@ CONFIG = { } -def format_datetime(dt): - return dt.astimezone(eastern).isoformat() +def format_date(dt): + dt = dt.astimezone(eastern) + return dt.strftime("%a %d").lower() def format_time(dt): + dt = dt.astimezone(eastern) return dt.strftime("%I:%M%p").lower() -def format_date(dt): - return dt.strftime("%a %d").lower() +def format_datetime(dt): + dt = dt.astimezone(eastern) + return f"{format_date(dt)} {format_time(dt)}" + def pollen_desc(index): From cfd49318cda6b6516632e7222a9e605d0ffa6058 Mon Sep 17 00:00:00 2001 From: Matthew Ryan Dillon Date: Mon, 26 May 2025 20:03:48 -0400 Subject: [PATCH 4/4] initial template --- template.liquid | 94 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 template.liquid diff --git a/template.liquid b/template.liquid new file mode 100644 index 0000000..6effdab --- /dev/null +++ b/template.liquid @@ -0,0 +1,94 @@ +
+
+ fetched: {{ fetched_at }} + {% for pollen in pollen %} + pollen index +
+

forecast at {{pollen.forecast_date}}

+
+ + + + {% for period in pollen.periods %} + + {% endfor %} + + + + + {% for period in pollen.periods %} + + {% endfor %} + + +
{{period.period}}
{{period.index}}
+ {% endfor %} + + {% for weather in weather %} + weather forecast +
+

forecast at {{weather.forecast_date}}

+
+ + + + + {% for period in weather.periods %} + + {% endfor %} + + + + + + {% for period in weather.periods %} + + {% endfor %} + + + + {% for period in weather.periods %} + + {% endfor %} + + + + {% for period in weather.periods %} + + {% endfor %} + + + + {% for period in weather.periods %} + + {% endfor %} + + + + {% for period in weather.periods %} + + {% endfor %} + + + + {% for period in weather.periods %} + + {% endfor %} + + + + {% for period in weather.periods %} + + {% endfor %} + + +
{{period.period}}
low{{period.low}} F
high{{period.high}} F
humidity{{period.humidity}}%
pressure{{period.pressure}}
sunrise{{period.sunrise}}
sunset{{period.sunset}}
desc{{period.desc}}
+ {% endfor %} +
+
+ {{ Content for column 2 }} +
+
+ {{ Content for column 3 }} +
+
\ No newline at end of file