From 6fa3d04aad627ffa4786b91acc24e4f3e8b70312 Mon Sep 17 00:00:00 2001 From: Sam Chudnick Date: Thu, 8 Jun 2023 06:41:20 -0400 Subject: Update API to use open-meteo. Further frontend development. --- templates/base.html | 31 ++++++++++---------- templates/daily.html | 13 --------- templates/hourly.html | 18 ------------ templates/index.html | 20 ++----------- templates/weather.html | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 94 insertions(+), 65 deletions(-) delete mode 100644 templates/daily.html delete mode 100644 templates/hourly.html create mode 100644 templates/weather.html (limited to 'templates') diff --git a/templates/base.html b/templates/base.html index d464a5a..6fe776a 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,21 +1,20 @@ - - - {% block title %} {% endblock %} - - - - + + + {% block title %} {% endblock %} + + + + -
- {% block content %} {% endblock %} -
+
+ {% block content %} {% endblock %} +
- -{% block scripts %}{% endblock %} - + + diff --git a/templates/daily.html b/templates/daily.html deleted file mode 100644 index 5eb765e..0000000 --- a/templates/daily.html +++ /dev/null @@ -1,13 +0,0 @@ -{% extends 'base.html' %} -{% block content %} -
-{% for item in data %} -
- {{ item.time.strftime("%a %x") }}
- {{ item.high }}°F / {{ item.low }}°F
- {{ item.short_forecast_am }}

-
-{% endfor %} -
-{% endblock %} - diff --git a/templates/hourly.html b/templates/hourly.html deleted file mode 100644 index 56f9d9b..0000000 --- a/templates/hourly.html +++ /dev/null @@ -1,18 +0,0 @@ -{% extends 'base.html' %} - -{% block content %} -
-{% for item in data %} -
- {{ item.time.strftime("%a %x %I:%M %p") }}
- {{ item.temp }}°F
- {{ item.humidity }}%
- {{ item.precip_chance }}%
- {{ item.precip_amount }}in
- {{ item.wind_speed }}MPH
- {{ item.wind_direction }}

-
-{% endfor %} -
-{% endblock %} - diff --git a/templates/index.html b/templates/index.html index 2d97379..a877fef 100644 --- a/templates/index.html +++ b/templates/index.html @@ -4,23 +4,7 @@

{% block title %} Enter a Location {% endblock %}

{{ form.csrf_token }} -

- {{ form.location.label }}
- {{ form.location }} -

-

- {{ form.days.label }}
- {{ form.days }} -

-

- {{ form.forecast_type.label }}
- {{ form.forecast_type }} -

-

{{ form.submit() }}

+ {{ form.location }} + {{ form.submit() }}
{% endblock %} - -
- {{ form.name.label }} {{ form.name(size=20) }} - -
diff --git a/templates/weather.html b/templates/weather.html new file mode 100644 index 0000000..24819dc --- /dev/null +++ b/templates/weather.html @@ -0,0 +1,77 @@ +{% extends 'base.html' %} +{% block content %} +{% set is_day = data["current_weather"]["is_day"] %} +
+ +
+ {% set weather_code = data["current_weather"]["weathercode"] %} +
+
{{ weather_codes[weather_code] }}
+
{{ data["current_weather"]["temperature"]}}°F
+
Wind: {{ data["current_weather"]["windspeed"] }} MPH {{ data["current_weather"]["winddirection"] }}
+
Sunrise: {{ data["daily"]["sunrise"][0] }}
+
Sunset: {{ data["daily"]["sunset"][0] }}
+
+
+ +
+
+

Hourly Forecast

+
+ {% for i in range(hour, hour + 24) %} +
+
+
{{ data["hourly"]["time"][i] }}
+
+ {{ weather_codes[data["hourly"]["weathercode"][i]] }} + {% if data["hourly"]["weathercode"][i] > 50 %} + ({{ data["hourly"]["precipitation"][i] }}in, {{ data["hourly"]["precipitation_probability"][i] }}%) + {% endif %} +
+
{{ data["hourly"]["temperature_2m"][i]}}°F
+
Humidity: {{ data["hourly"]["relativehumidity_2m"][i] }}%
+
Wind: {{ data["hourly"]["windspeed_10m"][i] }}MPH {{ data["hourly"]["winddirection_10m"][i] }}
+
+
+ {% set weather_code = data["hourly"]["weathercode"][i] %} + +
+
+ {% endfor %} +
+
+

Daily Forecast

+
+
+ {% for i in range(7) %} +
+
+
{{ data["daily"]["time"][i] }}
+
+ {{ weather_codes[data["daily"]["weathercode"][i]] }} + {% if data["daily"]["weathercode"][i] > 50 %} + ({{ data["daily"]["precipitation_sum"][i] }}in, {{ data["daily"]["precipitation_probability_max"][i] }}%) + {% endif %} +
+
High: {{ data["daily"]["temperature_2m_max"][i] }}°F
+
Low: {{ data["daily"]["temperature_2m_min"][i] }}°F
+
Sunrise: {{ data["daily"]["sunrise"][i] }}
+
Sunset: {{ data["daily"]["sunset"][i] }}
+
+
+ {% set weather_code = data["daily"]["weathercode"][i] %} + +
+
+ {% endfor %} +
+ +
+{% endblock %} + -- cgit v1.2.3