doing updating UI, adding jinja filters
This commit is contained in:
@@ -4,7 +4,9 @@ from flask import (
|
||||
from werkzeug.exceptions import abort
|
||||
from datetime import datetime
|
||||
|
||||
from weather.db import get_db
|
||||
from weather.db import (
|
||||
get_db, close_db
|
||||
)
|
||||
from weather.ingest import (
|
||||
fetchHourlyForecasts, fetchDailyForecasts
|
||||
)
|
||||
@@ -51,6 +53,7 @@ def index():
|
||||
'SELECT * FROM `current_forecasts` WHERE `start_time` > DATETIME("now", "+1 hour") LIMIT 7'
|
||||
).fetchall()
|
||||
|
||||
close_db()
|
||||
return render_template(
|
||||
'weather/index.html',
|
||||
condition_image=condition_image,
|
||||
@@ -61,7 +64,7 @@ def index():
|
||||
|
||||
def mapForecastToImage(condition: str):
|
||||
if not condition:
|
||||
return 'cloudy'
|
||||
return 'clear'
|
||||
|
||||
condition = condition.lower()
|
||||
if 'thunder' in condition or 'storm' in condition:
|
||||
@@ -76,9 +79,9 @@ def mapForecastToImage(condition: str):
|
||||
return 'clear'
|
||||
elif 'cloud' in condition or 'overcast' in condition:
|
||||
return 'cloudy'
|
||||
elif 'fog' in condition or 'mist' in condition:
|
||||
return 'cloudy'
|
||||
elif 'haze' in condition or 'mist' in condition or 'fog' in condition:
|
||||
return 'hazy'
|
||||
else:
|
||||
return 'cloudy'
|
||||
return 'clear'
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user