Refactored JsonPayload to JsonResponse
This commit is contained in:
parent
d13341dd5b
commit
6581385ab9
16 changed files with 37 additions and 43 deletions
|
|
@ -3,7 +3,7 @@ from werkzeug.exceptions import BadRequest
|
|||
from flask import url_for
|
||||
|
||||
|
||||
class JsonPayload:
|
||||
class JsonResponse:
|
||||
def __init__(self, request):
|
||||
"""
|
||||
Object to wrap up simple functionality for parsing a JSON response.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from openflexure_microscope.api.utilities import gen, JsonPayload
|
||||
from openflexure_microscope.api.utilities import gen, JsonResponse
|
||||
from openflexure_microscope.api.v1.views import MicroscopeView
|
||||
|
||||
from flask import Response, Blueprint, jsonify, request
|
||||
|
|
@ -203,7 +203,7 @@ class ConfigAPI(MicroscopeView):
|
|||
:status 200: capture created
|
||||
|
||||
"""
|
||||
payload = JsonPayload(request)
|
||||
payload = JsonResponse(request)
|
||||
|
||||
logging.debug("Updating settings from POST request:")
|
||||
logging.debug(payload.json)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from openflexure_microscope.api.utilities import get_bool, JsonPayload
|
||||
from openflexure_microscope.api.utilities import get_bool, JsonResponse
|
||||
from openflexure_microscope.api.v1.views import MicroscopeView
|
||||
from openflexure_microscope.utilities import filter_dict
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ class ListAPI(MicroscopeView):
|
|||
:<header Content-Type: application/json
|
||||
:status 200: capture created
|
||||
"""
|
||||
payload = JsonPayload(request)
|
||||
payload = JsonResponse(request)
|
||||
|
||||
filename = payload.param('filename')
|
||||
temporary = payload.param('temporary', default=False, convert=bool)
|
||||
|
|
@ -258,7 +258,7 @@ class CaptureAPI(MicroscopeView):
|
|||
if not capture_obj:
|
||||
return abort(404) # 404 Not Found
|
||||
|
||||
data_dict = JsonPayload(request).json
|
||||
data_dict = JsonResponse(request).json
|
||||
|
||||
capture_obj.put_metadata(data_dict)
|
||||
|
||||
|
|
@ -463,7 +463,7 @@ class TagsAPI(MicroscopeView):
|
|||
if not capture_obj or not capture_obj.state['available']:
|
||||
return abort(404) # 404 Not Found
|
||||
|
||||
data_dict = JsonPayload(request).json
|
||||
data_dict = JsonResponse(request).json
|
||||
|
||||
if type(data_dict) != list:
|
||||
return abort(400)
|
||||
|
|
@ -499,7 +499,7 @@ class TagsAPI(MicroscopeView):
|
|||
if not capture_obj:
|
||||
return abort(404) # 404 Not Found
|
||||
|
||||
data_dict = JsonPayload(request).json
|
||||
data_dict = JsonResponse(request).json
|
||||
|
||||
if type(data_dict) != list:
|
||||
return abort(400)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
from openflexure_microscope.api.v1.views import MicroscopeView
|
||||
from openflexure_microscope.api.utilities import JsonPayload
|
||||
from openflexure_microscope.api.utilities import JsonResponse
|
||||
|
||||
from flask import jsonify, request
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ class ZoomAPI(MicroscopeView):
|
|||
:<header Content-Type: application/json
|
||||
:status 200: preview started/stopped
|
||||
"""
|
||||
payload = JsonPayload(request)
|
||||
payload = JsonResponse(request)
|
||||
zoom_value = payload.param('zoom_value', default=1.0, convert=float)
|
||||
|
||||
self.microscope.camera.set_zoom(zoom_value)
|
||||
|
|
@ -93,7 +93,7 @@ class OverlayAPI(MicroscopeView):
|
|||
:status 200: preview started/stopped
|
||||
"""
|
||||
|
||||
payload = JsonPayload(request)
|
||||
payload = JsonResponse(request)
|
||||
text = payload.param('text', default="", convert=str)
|
||||
size = payload.param('size', default=50, convert=int)
|
||||
|
||||
|
|
|
|||
|
|
@ -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 MicroscopeView
|
||||
|
||||
from flask import jsonify, request
|
||||
|
|
@ -37,7 +37,7 @@ class GPUPreviewAPI(MicroscopeView):
|
|||
:status 200: preview started/stopped
|
||||
"""
|
||||
if operation == "start":
|
||||
payload = JsonPayload(request)
|
||||
payload = JsonResponse(request)
|
||||
|
||||
window = payload.param('window', default=[])
|
||||
logging.debug(window)
|
||||
|
|
|
|||
|
|
@ -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 MicroscopeView
|
||||
from openflexure_microscope.utilities import axes_to_array, filter_dict
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ class PositionAPI(MicroscopeView):
|
|||
|
||||
"""
|
||||
# Create response object
|
||||
payload = JsonPayload(request)
|
||||
payload = JsonResponse(request)
|
||||
logging.debug(payload.json)
|
||||
|
||||
# Construct position array
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue