Loading openflexure_microscope/api/v1.py +12 −15 Original line number Diff line number Diff line #!/usr/bin/env python """ TODO: Add proper docstrings TODO: Bind to port 80 TODO: Reimplement capture methods TODO: Implement API route to cleanly shut down server TODO: Implement microscope function API routes (autofocus etc) """ Loading Loading @@ -30,17 +28,11 @@ import logging, sys logging.basicConfig(stream=sys.stderr, level=logging.DEBUG) # Create a dummy microscope object, with no hardware attachments api_microscope = Microscope(None, None) logging.debug("Created an empty microscope in global.") # Create flask app app = Flask(__name__) # Make errors more API friendly @app.errorhandler(404) def not_found(error): return make_response(jsonify({'error': 'Not found'}), 404) # Some useful functions # TODO: Maybe auto-generate API URI base from module name # Generate API URI based on version from filename def uri(suffix, base=None): if not base: api_ver = os.path.splitext(os.path.basename(__file__))[0] Loading @@ -49,9 +41,14 @@ def uri(suffix, base=None): logging.debug("Created app route: {}".format(uri)) return uri # Create a dummy microscope object, with no hardware attachments api_microscope = Microscope(None, None) logging.debug("Created an empty microscope in global.") # Create flask app app = Flask(__name__) # Make errors more API friendly @app.errorhandler(404) def not_found(error): return make_response(jsonify({'error': 'Not found'}), 404) # After app starts, but before first request, attach hardware to global microscope @app.before_first_request Loading Loading
openflexure_microscope/api/v1.py +12 −15 Original line number Diff line number Diff line #!/usr/bin/env python """ TODO: Add proper docstrings TODO: Bind to port 80 TODO: Reimplement capture methods TODO: Implement API route to cleanly shut down server TODO: Implement microscope function API routes (autofocus etc) """ Loading Loading @@ -30,17 +28,11 @@ import logging, sys logging.basicConfig(stream=sys.stderr, level=logging.DEBUG) # Create a dummy microscope object, with no hardware attachments api_microscope = Microscope(None, None) logging.debug("Created an empty microscope in global.") # Create flask app app = Flask(__name__) # Make errors more API friendly @app.errorhandler(404) def not_found(error): return make_response(jsonify({'error': 'Not found'}), 404) # Some useful functions # TODO: Maybe auto-generate API URI base from module name # Generate API URI based on version from filename def uri(suffix, base=None): if not base: api_ver = os.path.splitext(os.path.basename(__file__))[0] Loading @@ -49,9 +41,14 @@ def uri(suffix, base=None): logging.debug("Created app route: {}".format(uri)) return uri # Create a dummy microscope object, with no hardware attachments api_microscope = Microscope(None, None) logging.debug("Created an empty microscope in global.") # Create flask app app = Flask(__name__) # Make errors more API friendly @app.errorhandler(404) def not_found(error): return make_response(jsonify({'error': 'Not found'}), 404) # After app starts, but before first request, attach hardware to global microscope @app.before_first_request Loading