# HG changeset patch # User Paul Fisher # Date 1569734298 14400 # Node ID cda47993a1937ab0939fb720e5dcba4c2fa1dffe # Parent f66df122f18d63645d0019588d4ff0761160c410 server: fix bugs and improve template. diff -r f66df122f18d -r cda47993a193 weather_server/server.py --- a/weather_server/server.py Sun Sep 29 00:52:13 2019 -0400 +++ b/weather_server/server.py Sun Sep 29 01:18:18 2019 -0400 @@ -25,7 +25,7 @@ if not target: flask.abort(404) try: - target_loc = locs.get(target) + target_loc, logger = locs.get(target) except KeyError: flask.abort(404) @@ -43,8 +43,8 @@ ) for item in reader ] - target_loc.logger.write_rows(entries) - return {'status': 'OK'} + logger.write_rows(entries) + return flask.jsonify({'status': 'OK'}) @app.route('/') def show(location): @@ -55,7 +55,7 @@ data = logger.data if data: last_reading = data[-1] - tz = loc.timezone + tz = loc.timezone() date = tz.normalize(last_reading.sample_time.astimezone(tz)) else: last_reading = None diff -r f66df122f18d -r cda47993a193 weather_server/templates/location.html --- a/weather_server/templates/location.html Sun Sep 29 00:52:13 2019 -0400 +++ b/weather_server/templates/location.html Sun Sep 29 01:18:18 2019 -0400 @@ -6,7 +6,8 @@ {% if last_reading %} Temperature: {{ last_reading.temp_f }}
- Dew point: {{ last_reading.dew_point_f }} + Dew point: {{ last_reading.dew_point_f }}
+ As of: {{ date }} {% else %} No weather yet {% endif %}