Add 5 latest readings to the bottom of the page

This commit is contained in:
Gogs 2017-02-03 00:32:23 -05:00
parent 030dc33d55
commit 7d760985b8
2 changed files with 22 additions and 8 deletions

View File

@ -16,7 +16,10 @@ def success():
@app.route('/', methods=['GET', 'POST']) @app.route('/', methods=['GET', 'POST'])
def main_page(): 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']) @app.route('/add_time', methods=['POST', 'GET'])
def add_time(): def add_time():
@ -32,6 +35,8 @@ def add_time():
time = now time = now
odometer = request.form['odometer'] odometer = request.form['odometer']
oilhealth= request.form['oilhealth'] oilhealth= request.form['oilhealth']
if oilhealth != '':
oilhealth = float(oilhealth)
fuel = request.form['fuel'] fuel = request.form['fuel']
if fuel != '': if fuel != '':
fuel = float(fuel) fuel = float(fuel)

View File

@ -27,21 +27,21 @@
<div class="row"> <div class="row">
<div class="col-xs-4"> <div class="col-xs-4">
<label for="odometer">Odometer:</label> <label for="odometer">Odometer:</label>
<input type=text name="odometer" class="form-control" placeholder="Ex: 3008"> <input type=number name="odometer" class="form-control" placeholder="Ex: 3008">
</div> </div>
<div class="col-xs-4"> <div class="col-xs-4">
<label for="oilhealth">Oil Health:</label> <label for="oilhealth">Oil Health:</label>
<input type=text name="oilhealth" class="form-control" placeholder="Ex: 80"> <input type=number name="oilhealth" class="form-control" placeholder="Ex: 80">
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-xs-4"> <div class="col-xs-4">
<label for="fuel">Fuel (L):</label> <label for="fuel">Fuel (L):</label>
<input type=text name="fuel" class="form-control" placeholder="Ex: 70.175"> <input type=number name="fuel" class="form-control" placeholder="Ex: 70.175">
</div> </div>
<div class="col-xs-4"> <div class="col-xs-4">
<label for="fuelcost">Fuel Cost ($/L):</label> <label for="fuelcost">Fuel Cost ($/L):</label>
<input type=text name="fuelcost" class="form-control" placeholder="Ex: 1.059"> <input type=number name="fuelcost" class="form-control" placeholder="Ex: 1.059">
</div> </div>
</div> </div>
<div class="row"> <div class="row">
@ -52,10 +52,19 @@
<option value="false">False</option> <option value="false">False</option>
</select> </select>
</div> </div>
</div> </div><br>
<input type="submit" value="Go"> <input type="submit" value="Go">
</div> </div>
</form> </form>
<br>
Last Mileage
<ul>
{% for point in data %}
{% for item in point %}
<li>
{{ item['top'] }}
</li>
{% endfor %}
{% endfor %}
{% endblock %} {% endblock %}
</ul>