Skip to content

Commit

Permalink
return dummy field instead of http status code 503
Browse files Browse the repository at this point in the history
  • Loading branch information
jklmnn committed Dec 29, 2017
1 parent e0df1f6 commit 07efdfb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion park_api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
app = Flask(__name__)

cache = {}
empty = {
'last_downloaded': '1970-01-01T00:00:00',
'last_updated': '1970-01-01T00:00:00',
'lots':[]
}

def user_agent(request):
ua = request.headers.get("User-Agent")
Expand Down Expand Up @@ -85,7 +90,7 @@ def get_lots(city):
data = raw["data"]
cache[city] = (raw["timestamp_downloaded"], jsonify(data))
except IndexError:
return ("Error 503: There is currently no data available for " + city + ".", 503)
return jsonify(empty)
except (psycopg2.OperationalError, psycopg2.ProgrammingError) as e:
app.logger.error("Unable to connect to database: " + str(e))
abort(500)
Expand Down

0 comments on commit 07efdfb

Please sign in to comment.