...
 
Commits (2)
......@@ -101,10 +101,10 @@ def get_app(config):
app.route("/api/v1/ics/visits.ics", ["GET", "OPTIONS"],
api_routes.ics_feed_v1)
app.route("/api/v1/search", "POST", api_routes.search_v1)
app.route("/api/v1/search", ["POST", "OPTIONS"], api_routes.search_v1)
app.route("/api/v1/opendata", "GET", api_routes.opendata_index_v1)
app.route("/api/v1/opendata/postal_codes", "GET",
app.route("/api/v1/opendata", ["GET", "OPTIONS"], api_routes.opendata_index_v1)
app.route("/api/v1/opendata/postal_codes", ["GET", "OPTIONS"],
api_routes.opendata_postal_codes_v1)
app.route("/api/v1/metadata", ["GET", "OPTIONS"], api_routes.metadata_v1)
......
......@@ -439,6 +439,10 @@ def opendata_index_v1():
GET /api/v1/opendata
"""
if bottle.request.method == 'OPTIONS':
# CORS
return {}
return {
"postal_codes": "/api/v1/opendata/postal_codes"
}
......@@ -517,14 +521,19 @@ def metadata_v1(config):
return {}
try:
ts_file = os.path.join(
config['data_directory'],
'timestamp'
)
ts = os.path.getmtime(ts_file)
last_update = None
try:
ts_file = os.path.join(
config['data_directory'],
'timestamp'
)
last_update = os.path.getmtime(ts_file)
except OSError:
pass
return {
'data': {
'last_update': ts
'last_update': last_update
}
}
except Exception as exc: # pylint: disable= broad-except
......