diff options
author | Matt Kohls <mattkohls13@gmail.com> | 2016-04-13 00:50:54 -0400 |
---|---|---|
committer | Matt Kohls <mattkohls13@gmail.com> | 2016-04-13 00:50:54 -0400 |
commit | b34f83f65e4d2f74844d19a4974f96143fdd8136 (patch) | |
tree | 7fa978dae4eb61d9bd77ae82f895ce4d9177d8f4 /sensor.py | |
parent | d48715b967e7ba5bf87fe2df8ff31654cfb35b18 (diff) | |
download | Sensor-Server-b34f83f65e4d2f74844d19a4974f96143fdd8136.tar.gz Sensor-Server-b34f83f65e4d2f74844d19a4974f96143fdd8136.tar.bz2 Sensor-Server-b34f83f65e4d2f74844d19a4974f96143fdd8136.zip |
Initial graph working
sensor.py
added route to draw graph
show_entries.html
added spot for graph
reformatted tabs
Diffstat (limited to 'sensor.py')
-rw-r--r-- | sensor.py | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -44,13 +44,28 @@ def show_entries(): cur = g.db.execute('SELECT date, temperature, humidity, pressure FROM weather ORDER BY id desc') entries = [dict(date=row[0], temperature=row[1], humidity=row[2], pressure=row[3]) for row in cur.fetchall()] + # datetimeline = pygal.DateTimeLine( + # x_label_rotation=30, truncate_label=-1, + # x_value_formatter=lambda dt: dt.strftime('%d, %b %Y %I:%M %p') + # ) + # datetimeline.add("Temp F", [(row[0], row[1]) for row in cur.fetchall()]) + # datetimeline.render_response() + + # return render_template('show_entries.html', wgraph=datetimeline, weather=entries) + return render_template('show_entries.html', weather=entries) + +@app.route('/wgraph.svg') +def weather_route(): + cur = g.db.execute('SELECT date, temperature, humidity, pressure FROM weather ORDER BY id desc') + datetimeline = pygal.DateTimeLine( x_label_rotation=30, truncate_label=-1, x_value_formatter=lambda dt: dt.strftime('%d, %b %Y %I:%M %p') ) datetimeline.add("Temp F", [(row[0], row[1]) for row in cur.fetchall()]) - return render_template('show_entries.html', wgraph=datetimeline, weather=entries) + return datetimeline.render_response() + # adding entries to database @app.route('/data', methods=['POST']) |