Refactored JsonPayload to JsonResponse
This commit is contained in:
parent
d13341dd5b
commit
6581385ab9
16 changed files with 37 additions and 43 deletions
|
|
@ -1,17 +1,17 @@
|
|||
import numpy as np
|
||||
import logging
|
||||
|
||||
from openflexure_microscope.devel import MicroscopeViewPlugin, JsonPayload, request, jsonify
|
||||
from openflexure_microscope.devel import MicroscopeViewPlugin, JsonResponse, request, jsonify
|
||||
|
||||
class MeasureSharpnessAPI(MicroscopeViewPlugin):
|
||||
def post(self):
|
||||
payload = JsonPayload(request)
|
||||
payload = JsonResponse(request)
|
||||
return jsonify({'sharpness': self.plugin.measure_sharpness()})
|
||||
|
||||
|
||||
class AutofocusAPI(MicroscopeViewPlugin):
|
||||
def post(self):
|
||||
payload = JsonPayload(request)
|
||||
payload = JsonResponse(request)
|
||||
|
||||
# Figure out the range of z values to use
|
||||
dz = payload.param("dz", default=np.linspace(-300, 300, 7), convert=np.array)
|
||||
|
|
@ -24,7 +24,7 @@ class AutofocusAPI(MicroscopeViewPlugin):
|
|||
|
||||
class FastAutofocusAPI(MicroscopeViewPlugin):
|
||||
def post(self):
|
||||
payload = JsonPayload(request)
|
||||
payload = JsonResponse(request)
|
||||
|
||||
# Figure out the parameters to use
|
||||
dz = payload.param("dz", default=2000, convert=int)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from openflexure_microscope.devel import MicroscopePlugin, MicroscopeViewPlugin, JsonPayload, request, jsonify
|
||||
from openflexure_microscope.devel import MicroscopePlugin, MicroscopeViewPlugin, JsonResponse, request, jsonify
|
||||
|
||||
import logging
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
from openflexure_microscope.devel import MicroscopeViewPlugin, JsonPayload, request, jsonify, abort
|
||||
from openflexure_microscope.devel import MicroscopeViewPlugin, JsonResponse, request, jsonify, abort
|
||||
|
||||
import logging
|
||||
|
||||
class TileScanAPI(MicroscopeViewPlugin):
|
||||
def post(self):
|
||||
payload = JsonPayload(request)
|
||||
payload = JsonResponse(request)
|
||||
|
||||
# Get params
|
||||
filename = payload.param('filename')
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from openflexure_microscope.api.utilities import JsonPayload
|
||||
from openflexure_microscope.api.utilities import JsonResponse
|
||||
from openflexure_microscope.api.v1.views import MicroscopeViewPlugin
|
||||
from openflexure_microscope.exceptions import TaskDeniedException
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ class HelloWorldAPI(MicroscopeViewPlugin):
|
|||
Assumes request will include a JSON payload.
|
||||
"""
|
||||
# Get payload JSON
|
||||
payload = JsonPayload(request)
|
||||
payload = JsonResponse(request)
|
||||
|
||||
# Extract a value from the JSON key 'plugin_string', and convert to a string. If no value is given, default to empty.
|
||||
new_plugin_string = payload.param('plugin_string', default='', convert=str)
|
||||
|
|
@ -61,7 +61,7 @@ class LongRunningAPI(MicroscopeViewPlugin):
|
|||
Method to call when an HTTP POST request is made.
|
||||
"""
|
||||
# Get payload JSON
|
||||
payload = JsonPayload(request)
|
||||
payload = JsonResponse(request)
|
||||
|
||||
# Extract a values from the JSON payload.
|
||||
time_to_run = payload.param('time', default=10, convert=int)
|
||||
|
|
@ -84,7 +84,7 @@ class SomeExceptionAPI(MicroscopeViewPlugin):
|
|||
Method to call when an HTTP POST request is made.
|
||||
"""
|
||||
# Get payload JSON
|
||||
payload = JsonPayload(request)
|
||||
payload = JsonResponse(request)
|
||||
|
||||
# Attach the long-running method as a microscope task
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from openflexure_microscope.devel import MicroscopeViewPlugin, TaskDeniedException, JsonPayload, Response, request, escape, jsonify
|
||||
from openflexure_microscope.devel import MicroscopeViewPlugin, TaskDeniedException, JsonResponse, Response, request, escape, jsonify
|
||||
|
||||
import logging
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ class DoAPI(MicroscopeViewPlugin):
|
|||
|
||||
def post(self):
|
||||
# Get payload JSON
|
||||
payload = JsonPayload(request)
|
||||
payload = JsonResponse(request)
|
||||
|
||||
# Extract a values from the JSON payload.
|
||||
val_int = payload.param('val_int', default=None, convert=int)
|
||||
|
|
@ -49,7 +49,7 @@ class TaskAPI(MicroscopeViewPlugin):
|
|||
|
||||
def post(self):
|
||||
# Get payload JSON
|
||||
payload = JsonPayload(request)
|
||||
payload = JsonResponse(request)
|
||||
|
||||
# Extract a values from the JSON payload.
|
||||
val_int = payload.param('run_time', default=5, convert=int)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue