Mercurial > personal > weather-server
diff weather_server/server.py @ 2:cda47993a193
server: fix bugs and improve template.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Sun, 29 Sep 2019 01:18:18 -0400 |
parents | f66df122f18d |
children | b42c4bfe57c7 |
line wrap: on
line diff
--- 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('/<location>') 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