Add API endpoint for current snapshot (#359)

This commit is contained in:
Unpublished
2022-01-08 16:38:42 +01:00
committed by GitHub
parent bc74227635
commit bd8f389a65
2 changed files with 94 additions and 0 deletions

View File

@@ -744,6 +744,26 @@ def changedetection_app(config=None, datastore_o=None):
uuid=uuid)
return output
@app.route("/api/<string:uuid>/snapshot/current", methods=['GET'])
@login_required
def api_snapshot(uuid):
# More for testing, possible to return the first/only
if uuid == 'first':
uuid = list(datastore.data['watching'].keys()).pop()
try:
watch = datastore.data['watching'][uuid]
except KeyError:
return abort(400, "No history found for the specified link, bad link?")
newest = list(watch['history'].keys())[-1]
with open(watch['history'][newest], 'r') as f:
content = f.read()
resp = make_response(content)
resp.headers['Content-Type'] = 'text/plain'
return resp
@app.route("/favicon.ico", methods=['GET'])
def favicon():