moving API route to separate file
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from flask import (
|
||||
Blueprint, flash, g, render_template, request, url_for
|
||||
Blueprint, render_template
|
||||
)
|
||||
from werkzeug.exceptions import abort
|
||||
|
||||
@@ -35,15 +35,3 @@ def index():
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user