Loading openflexure_microscope/api/v1/blueprints/camera/__init__.py +7 −3 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ from openflexure_microscope.api.v1.views import MicroscopeView from flask import Blueprint from . import capture, record, preview, config, overlay from . import capture, record, preview, config, function def construct_blueprint(microscope_obj): Loading Loading @@ -31,9 +31,13 @@ def construct_blueprint(microscope_obj): '/preview/<string:operation>', view_func=preview.GPUPreviewAPI.as_view('gpu_preview', microscope=microscope_obj)) # Overlay routes # Function routes blueprint.add_url_rule( '/overlay', view_func=overlay.OverlayAPI.as_view('overlay', microscope=microscope_obj)) view_func=function.OverlayAPI.as_view('overlay', microscope=microscope_obj)) blueprint.add_url_rule( '/zoom', view_func=function.ZoomAPI.as_view('zoom', microscope=microscope_obj)) return(blueprint) No newline at end of file openflexure_microscope/api/v1/blueprints/camera/overlay.py→openflexure_microscope/api/v1/blueprints/camera/function.py +50 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,56 @@ from openflexure_microscope.api.utilities import JsonPayload from flask import Response, Blueprint, jsonify, request, abort, url_for, redirect, send_file import logging class ZoomAPI(MicroscopeView): def get(self): """ Get the current zoom value .. :quickref: Zoom; Get the zoom value :>header Accept: application/json :<header Content-Type: application/json :status 200: preview started/stopped """ zoom_value = self.microscope.camera.state['zoom_value'] return jsonify({'zoom_value': zoom_value}) def post(self): """ Change the current zoom value .. :quickref: Zoom; Set the zoom value **Example requests**: .. sourcecode:: http POST /camera/zoom HTTP/1.1 Accept: application/json { "zoom_value": 2.5, } :>header Accept: application/json :<header Content-Type: application/json :status 200: preview started/stopped """ payload = JsonPayload(request) zoom_value = payload.param('zoom_value', default=1.0, convert=float) self.microscope.camera.set_zoom(zoom_value) return jsonify(self.microscope.state) class OverlayAPI(MicroscopeView): def get(self): Loading Loading
openflexure_microscope/api/v1/blueprints/camera/__init__.py +7 −3 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ from openflexure_microscope.api.v1.views import MicroscopeView from flask import Blueprint from . import capture, record, preview, config, overlay from . import capture, record, preview, config, function def construct_blueprint(microscope_obj): Loading Loading @@ -31,9 +31,13 @@ def construct_blueprint(microscope_obj): '/preview/<string:operation>', view_func=preview.GPUPreviewAPI.as_view('gpu_preview', microscope=microscope_obj)) # Overlay routes # Function routes blueprint.add_url_rule( '/overlay', view_func=overlay.OverlayAPI.as_view('overlay', microscope=microscope_obj)) view_func=function.OverlayAPI.as_view('overlay', microscope=microscope_obj)) blueprint.add_url_rule( '/zoom', view_func=function.ZoomAPI.as_view('zoom', microscope=microscope_obj)) return(blueprint) No newline at end of file
openflexure_microscope/api/v1/blueprints/camera/overlay.py→openflexure_microscope/api/v1/blueprints/camera/function.py +50 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,56 @@ from openflexure_microscope.api.utilities import JsonPayload from flask import Response, Blueprint, jsonify, request, abort, url_for, redirect, send_file import logging class ZoomAPI(MicroscopeView): def get(self): """ Get the current zoom value .. :quickref: Zoom; Get the zoom value :>header Accept: application/json :<header Content-Type: application/json :status 200: preview started/stopped """ zoom_value = self.microscope.camera.state['zoom_value'] return jsonify({'zoom_value': zoom_value}) def post(self): """ Change the current zoom value .. :quickref: Zoom; Set the zoom value **Example requests**: .. sourcecode:: http POST /camera/zoom HTTP/1.1 Accept: application/json { "zoom_value": 2.5, } :>header Accept: application/json :<header Content-Type: application/json :status 200: preview started/stopped """ payload = JsonPayload(request) zoom_value = payload.param('zoom_value', default=1.0, convert=float) self.microscope.camera.set_zoom(zoom_value) return jsonify(self.microscope.state) class OverlayAPI(MicroscopeView): def get(self): Loading