diff options
| -rw-r--r-- | README.md | 6 | ||||
| -rw-r--r-- | geshem.py | 11 |
2 files changed, 12 insertions, 5 deletions
@@ -5,7 +5,7 @@ A rain radar clone for Mapbox GL, see it live at: [http://geshem.space](http://g ## Dev - Python 3.5 - - Redis + - Redis (optional, recommended) Setup a virtualenv: @@ -14,8 +14,10 @@ $ mkvirtualenv -p `which python3` geshem $ pip install -r requirements.txt ``` -Make sure you have a stupid `redis-server` running on localhost, then just run: +Then just run: ```bash $ python geshem.py ``` + +Make sure you have a stupid `redis-server` running on localhost to enjoy some sane caching. @@ -4,6 +4,7 @@ import requests from flask import Flask, render_template from os import environ from pathlib import Path +from redis.exceptions import ConnectionError MAPS_JSON = 'http://map.govmap.gov.il/rainradar/radar.json' STATIC_DIR = Path(__file__).resolve().parents[0] / 'static' @@ -28,9 +29,13 @@ def home(): @app.after_request def update_images(response): # poor man's background task - if not redis.get('fresh'): - redis.setex('fresh', 'yes', 60) - fetch_latest_images() + try: + if not redis.get('fresh'): + redis.setex('fresh', 'yes', 60) + fetch_latest_images() + except ConnectionError as e: + if app.debug: + fetch_latest_images() return response if __name__ == '__main__': |
