Compare commits

..

5 Commits

Author SHA1 Message Date
a5af30df6f adding screenshot file 2026-01-12 15:16:31 -07:00
e291f232ba adding screenshot 2026-01-12 15:16:13 -07:00
3b3d7c5247 get the correct current forecast 2026-01-12 15:14:11 -07:00
1dc30200fd adding build file 2026-01-12 15:10:06 -07:00
02d7245212 fixing API to return current conditions 2026-01-12 15:06:28 -07:00
4 changed files with 15 additions and 5 deletions

View File

@@ -1,3 +1,5 @@
# Weather (Python)
Recreating a weather reporting app from Laravel to Flask
<img src="./screenshot.png" width="200" />

12
pyproject.toml Normal file
View File

@@ -0,0 +1,12 @@
[project]
name = "weather"
version = "1.0.0"
description = "A little weather app"
dependencies = [
"flask",
"requests",
]
[build-system]
requires = ["flit_core<4"]
build-backend = "flit_core.buildapi"

BIN
screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 888 KiB

View File

@@ -10,12 +10,8 @@ bp = Blueprint('api', __name__)
@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"
"SELECT * FROM `current_forecasts` WHERE DATETIME('now', 'localtime') BETWEEN `start_time` AND `end_time` LIMIT 1"
).fetchone())
return current_conditions