a terrible but somewhat functional state

This commit is contained in:
2026-01-11 17:50:32 -07:00
parent 9dbd72f4ee
commit 7b5a49979e
12 changed files with 9814 additions and 26 deletions

View File

@@ -10,9 +10,40 @@ bp = Blueprint('weather', __name__)
@bp.route('/')
def index():
db = get_db()
latest_period = dict(db.execute(
'SELECT `id` FROM `reports` WHERE `type` = "hourly" ORDER BY `reported_at` DESC'
).fetchone())
current_conditions = dict(db.execute(
f"SELECT * FROM `periods` WHERE `report_id` = {latest_period['id']} LIMIT 1"
).fetchone())
# TODO: add conditions to check for day/night
condition_image = f"images/{current_conditions['short_forecast'].lower()}.jpg"
periods = db.execute(
'SELECT *'
' FROM `periods`'
' ORDER BY `id` DESC'
' LIMIT 7'
).fetchall()
return render_template('weather/index.html', periods=periods)
return render_template(
'weather/index.html',
current_conditions=current_conditions,
condition_image=condition_image,
periods=periods
)
@bp.route('/api')
def api():
db = get_db()
latest_period = dict(db.execute(
'SELECT `id` FROM `reports` WHERE `type` = "hourly" ORDER BY `reported_at` DESC'
).fetchone())
current_conditions = dict(db.execute(
f"SELECT * FROM `periods` WHERE `report_id` = {latest_period['id']} LIMIT 1"
).fetchone())
return current_conditions