From 7d760985b859dc10daa94827a26ba34c26cd680d Mon Sep 17 00:00:00 2001 From: Gogs Date: Fri, 3 Feb 2017 00:32:23 -0500 Subject: [PATCH] Add 5 latest readings to the bottom of the page --- influx_frontend.py | 7 ++++++- templates/index.html | 23 ++++++++++++++++------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/influx_frontend.py b/influx_frontend.py index ecba7cc..648c9c9 100644 --- a/influx_frontend.py +++ b/influx_frontend.py @@ -16,7 +16,10 @@ def success(): @app.route('/', methods=['GET', 'POST']) def main_page(): - return render_template('index.html') + client = InfluxDBClient('localhost', 8086, 'root', 'root', 'gas') + query = 'select TOP(odometer, 5) from odyssey' + data = client.query(query) + return render_template('index.html', data=data) @app.route('/add_time', methods=['POST', 'GET']) def add_time(): @@ -32,6 +35,8 @@ def add_time(): time = now odometer = request.form['odometer'] oilhealth= request.form['oilhealth'] + if oilhealth != '': + oilhealth = float(oilhealth) fuel = request.form['fuel'] if fuel != '': fuel = float(fuel) diff --git a/templates/index.html b/templates/index.html index 369e299..36d9a0f 100644 --- a/templates/index.html +++ b/templates/index.html @@ -27,21 +27,21 @@
- +
- +
- +
- +
@@ -52,10 +52,19 @@
- +
- +
+Last Mileage +