Commit fb1f848a authored by Joel Collins's avatar Joel Collins
Browse files

Updated example plugin to use new JsonPayload

parent 7a9629e7
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
from openflexure_microscope.api.utilities import parse_payload, get_from_payload
from openflexure_microscope.api.utilities import JsonPayload
from openflexure_microscope.api.v1.views import MicroscopeViewPlugin

from flask import request, Response, escape
@@ -41,10 +41,10 @@ class HelloWorldAPI(MicroscopeViewPlugin):
        Assumes request will include a JSON payload.
        """
        # Get payload JSON as a dictionary
        state = parse_payload(request)
        payload = JsonPayload(request)

        # Extract a value from the JSON key 'plugin_string'. If no value is given, default to None
        new_plugin_string = get_from_payload(state, 'plugin_string', default=None)
        new_plugin_string = payload.param('plugin_string')

        if new_plugin_string:  # If not None or empty
            # Set microscope attribute to the specified string