Made 404 errors more API friendly

This commit is contained in:
Joel Collins 2018-11-14 13:38:16 +00:00
parent b9410785e0
commit 0418afbdc5

View file

@ -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(),