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 diff --git a/main.py b/main.py index 95433e1..ac7fc42 100644 --- a/main.py +++ b/main.py @@ -27,16 +27,33 @@ 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): + 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): @@ -89,7 +106,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"] ], } 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