summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Adam <yuval@y3xz.com>2015-11-07 00:49:12 +0200
committerYuval Adam <yuval@y3xz.com>2015-11-07 00:49:12 +0200
commit111a7c21dac3fd3aa4ac85f62605d6f7fa0f4521 (patch)
tree2fff4f1059fc81cf2801d097321eb44c523bff24
parentd70e5e660c0b6585a4d1bc4bdd68e425c65e3459 (diff)
Fix update_images()
-rw-r--r--geshem.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/geshem.py b/geshem.py
index c15c8b1..1ad80ac 100644
--- a/geshem.py
+++ b/geshem.py
@@ -9,7 +9,7 @@ MAPS_JSON = 'http://map.govmap.gov.il/rainradar/radar.json'
STATIC_DIR = Path(__file__).resolve().parents[0] / 'static'
app = Flask(__name__)
-redis = redis.from_url(environ.get('REDIS_URL'))
+redis = redis.from_url(environ.get('REDIS_URL', 'redis://localhost'))
def fetch_latest_images():
maps_json = requests.get(MAPS_JSON).json()
@@ -26,11 +26,12 @@ def home():
return render_template('index.html')
@app.after_request
-def update_images():
+def update_images(response):
# poor man's background task
if not redis.get('fresh'):
- redis.setex('fresh', 60, 'yes')
+ redis.setex('fresh', 'yes', 60)
fetch_latest_images()
+ return response
if __name__ == '__main__':
app.run(debug=True)