homepage: sensor history json download
This commit is contained in:
parent
56fdb75831
commit
c29b3d49cf
5
app.py
5
app.py
|
@ -3,6 +3,7 @@ import json
|
|||
from flask import Flask, Response
|
||||
from flask import render_template, render_template_string, escape
|
||||
from flask import request, send_file
|
||||
from flask import jsonify
|
||||
from flask_socketio import SocketIO, join_room
|
||||
|
||||
from random import randint
|
||||
|
@ -81,6 +82,10 @@ def dist(filename):
|
|||
print('Missing', filename)
|
||||
return ''
|
||||
|
||||
@app.route('/sensors.json')
|
||||
def get_sensors():
|
||||
return jsonify(sensors.get_history())
|
||||
|
||||
@app.route('/recipe')
|
||||
def recipe():
|
||||
return render_template('recipe.html', recipe=phasectrl.recipe)
|
||||
|
|
|
@ -212,7 +212,7 @@ class Sensors():
|
|||
|
||||
def get_history(self, n=None):
|
||||
l = len(self.history)
|
||||
return tuple(islice(self.history, max(0, l - n), l))
|
||||
return tuple(islice(self.history, max(0, l - (n or l)), l))
|
||||
|
||||
sensors = Sensors()
|
||||
|
||||
|
|
|
@ -47,6 +47,9 @@
|
|||
Update #of points
|
||||
</a>
|
||||
</div>
|
||||
<a class="button is-link" href="/sensors.json">
|
||||
Download
|
||||
</a>
|
||||
</div>
|
||||
<div id="data-plot"></div>
|
||||
<br/>
|
||||
|
|
Loading…
Reference in New Issue