From a8c9a7e7dd8160070c65962d4e1b7bd57fad67c8 Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Tue, 15 Jan 2019 11:48:10 +0000 Subject: [PATCH] Route to return microscope config --- .../api/v1/blueprints/base.py | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/openflexure_microscope/api/v1/blueprints/base.py b/openflexure_microscope/api/v1/blueprints/base.py index 2cddf431..cf14617c 100644 --- a/openflexure_microscope/api/v1/blueprints/base.py +++ b/openflexure_microscope/api/v1/blueprints/base.py @@ -75,6 +75,69 @@ class StateAPI(MicroscopeView): return jsonify(self.microscope.state) +class ConfigAPI(MicroscopeView): + + def get(self): + """ + JSON representation of the microscope config. + + .. :quickref: Config; Microscope config + + **Example request**: + + .. sourcecode:: http + + GET /config/ HTTP/1.1 + Accept: application/json + + **Example response**: + + .. sourcecode:: http + + HTTP/1.1 200 OK + Vary: Accept + Content-Type: application/json + + { + "analog_gain": 1.0, + "digital_gain": 1.0, + "image_resolution": [ + 2592, + 1944 + ], + "jpeg_quality": 75, + "name": "0e2c6fac5421429aac67c7903107bdd8", + "numpy_resolution": [ + 1312, + 976 + ], + "picamera_params": { + "awb_gains": [ + 0.92578125, + 2.94921875 + ], + "awb_mode": "off", + "exposure_mode": "off", + "framerate": 24.0, + "saturation": 0, + "shutter_speed": 5378 + }, + "plugins": [ + "openflexure_microscope.plugins.default:Plugin" + ], + "shading_table_path": "/home/pi/.openflexure/microscopelst.npy", + "video_resolution": [ + 832, + 624 + ] + } + + :>header Accept: application/json + :>header Content-Type: application/json + :status 200: state available + """ + return jsonify(self.microscope.config) + def construct_blueprint(microscope_obj): blueprint = Blueprint('base_blueprint', __name__) @@ -89,4 +152,9 @@ def construct_blueprint(microscope_obj): view_func=StateAPI.as_view('state', microscope=microscope_obj) ) + blueprint.add_url_rule( + '/config', + view_func=ConfigAPI.as_view('config', microscope=microscope_obj) + ) + return(blueprint)