diff --git a/openflexure_microscope/api/v1.py b/openflexure_microscope/api/v1.py index 009435cc..8c50d524 100644 --- a/openflexure_microscope/api/v1.py +++ b/openflexure_microscope/api/v1.py @@ -14,7 +14,8 @@ import datetime from flask import ( Flask, render_template, Response, - redirect, request, jsonify, send_file, abort) + redirect, request, jsonify, send_file, abort, + make_response) import numpy as np @@ -29,6 +30,11 @@ import logging, sys logging.basicConfig(stream=sys.stderr, level=logging.DEBUG) +# Make errors more API friendly +@app.errorhandler(404) +def not_found(error): + return make_response(jsonify({'error': 'Not found'}), 404) + # Create the microscope object globally (common to all spawned server threads) microscope = Microscope( StreamingCamera(),