# snag # Matt Kohls # (c) 2023 from flask import ( Blueprint, flash, g, redirect, render_template, request, url_for ) from werkzeug.exceptions import abort from datetime import datetime from snag.db import get_db bp = Blueprint('dashboard', __name__) @bp.route('/') def dashboard(): db = get_db() rows = db.execute( 'SELECT de.deviceId, de.environment, de.environmentDescription, d.deviceName, d.deviceLocation' ' FROM device_env de JOIN devices d ON de.deviceId = d.deviceId' ' ORDER BY entry DESC' ).fetchall() deviceList = [dict(deviceId=row['deviceId'], environment=row['environment'], environmentDesc=row['environmentDescription'], name=row['deviceName'], location=row['deviceLocation']) for row in rows] return render_template('dashboard/dashboard.html', deviceList=deviceList, generatedAt=datetime.now())