Switched away from using JSONify
This commit is contained in:
parent
4fffa1fcba
commit
cda5cdbb44
9 changed files with 26 additions and 29 deletions
|
|
@ -8,7 +8,7 @@ import logging, logging.handlers
|
|||
import os
|
||||
import pkg_resources
|
||||
|
||||
from flask import Flask, jsonify, send_file
|
||||
from flask import Flask, send_file
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ def routes():
|
|||
"""
|
||||
List of all connected API routes
|
||||
"""
|
||||
return jsonify(list_routes(app))
|
||||
return list_routes(app)
|
||||
|
||||
|
||||
@app.route("/log")
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from labthings.server.extensions import BaseExtension
|
|||
from labthings.server.view import View
|
||||
from labthings.server.decorators import ThingAction, ThingProperty, marshal_task
|
||||
|
||||
from openflexure_microscope.devel import JsonResponse, request, jsonify, taskify, abort
|
||||
from openflexure_microscope.devel import JsonResponse, request, taskify, abort
|
||||
from openflexure_microscope.utilities import set_properties
|
||||
|
||||
import time
|
||||
|
|
@ -309,7 +309,7 @@ class MeasureSharpnessAPI(View):
|
|||
if not microscope:
|
||||
abort(503, "No microscope connected. Unable to measure sharpness.")
|
||||
|
||||
return jsonify({"sharpness": measure_sharpness(microscope)})
|
||||
return {"sharpness": measure_sharpness(microscope)}
|
||||
|
||||
|
||||
@ThingAction
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
from openflexure_microscope.devel import (
|
||||
JsonResponse,
|
||||
request,
|
||||
jsonify,
|
||||
taskify,
|
||||
update_task_progress,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ from openflexure_microscope.api.utilities.gui import build_gui
|
|||
|
||||
import logging
|
||||
|
||||
from flask import jsonify
|
||||
|
||||
# Some value that will change over time
|
||||
# Here, we add 1 to it every time a GET request is made
|
||||
val_int = 0
|
||||
|
|
@ -81,7 +79,7 @@ class TestAPIView(View):
|
|||
def get(self):
|
||||
global val_int
|
||||
val_int += 1
|
||||
return jsonify({"val": True})
|
||||
return {"val": True}
|
||||
|
||||
|
||||
@ThingAction
|
||||
|
|
@ -89,7 +87,7 @@ class TestDoAPIView(View):
|
|||
def post(self):
|
||||
global val_int
|
||||
val_int += 1
|
||||
return jsonify({"val": True})
|
||||
return {"val": True}
|
||||
|
||||
|
||||
# Using the dynamic form
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ from openflexure_microscope.api.v2.views.captures import capture_schema
|
|||
|
||||
import logging
|
||||
import io
|
||||
from flask import jsonify, request, abort, url_for, redirect, send_file
|
||||
from flask import request, abort, url_for, redirect, send_file
|
||||
|
||||
|
||||
@ThingAction
|
||||
|
|
@ -164,7 +164,7 @@ class GPUPreviewStartAPI(View):
|
|||
microscope.camera.start_preview(fullscreen=fullscreen, window=window)
|
||||
|
||||
# TODO: Make schema for microscope state
|
||||
return jsonify(microscope.state)
|
||||
return microscope.state
|
||||
|
||||
|
||||
@ThingAction
|
||||
|
|
@ -176,4 +176,4 @@ class GPUPreviewStopAPI(View):
|
|||
microscope = find_component("org.openflexure.microscope")
|
||||
microscope.camera.stop_preview()
|
||||
# TODO: Make schema for microscope state
|
||||
return jsonify(microscope.state)
|
||||
return microscope.state
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from labthings.server import fields
|
|||
|
||||
from openflexure_microscope.utilities import axes_to_array, filter_dict
|
||||
|
||||
from flask import Blueprint, jsonify, request
|
||||
from flask import Blueprint, request
|
||||
|
||||
import logging
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ class MoveStageAPI(View):
|
|||
logging.warning("Unable to move. No stage found.")
|
||||
|
||||
# TODO: Make schema for microscope state
|
||||
return jsonify(microscope.state["stage"]["position"])
|
||||
return microscope.state["stage"]["position"]
|
||||
|
||||
|
||||
@ThingAction
|
||||
|
|
@ -67,4 +67,4 @@ class ZeroStageAPI(View):
|
|||
microscope.stage.zero_position()
|
||||
|
||||
# TODO: Make schema for microscope state
|
||||
return jsonify(microscope.state["stage"])
|
||||
return microscope.state["stage"]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import logging
|
||||
from flask import abort, request, redirect, url_for, send_file, jsonify
|
||||
from flask import abort, request, redirect, url_for, send_file
|
||||
|
||||
from openflexure_microscope.api.utilities import get_bool, JsonResponse
|
||||
|
||||
|
|
@ -185,7 +185,7 @@ class CaptureTags(View):
|
|||
if not capture_obj:
|
||||
return abort(404) # 404 Not Found
|
||||
|
||||
return jsonify(capture_obj.tags)
|
||||
return capture_obj.tags
|
||||
|
||||
def put(self, id):
|
||||
"""
|
||||
|
|
@ -205,7 +205,7 @@ class CaptureTags(View):
|
|||
|
||||
capture_obj.put_tags(data_dict)
|
||||
|
||||
return jsonify(capture_obj.tags)
|
||||
return capture_obj.tags
|
||||
|
||||
def delete(self, id):
|
||||
"""
|
||||
|
|
@ -225,7 +225,7 @@ class CaptureTags(View):
|
|||
for tag in data_dict:
|
||||
capture_obj.delete_tag(str(tag))
|
||||
|
||||
return jsonify(capture_obj.tags)
|
||||
return capture_obj.tags
|
||||
|
||||
|
||||
@Tag("captures")
|
||||
|
|
@ -240,7 +240,7 @@ class CaptureAnnotations(View):
|
|||
if not capture_obj:
|
||||
return abort(404) # 404 Not Found
|
||||
|
||||
return jsonify(capture_obj.annotations)
|
||||
return capture_obj.annotations
|
||||
|
||||
def put(self, id):
|
||||
"""
|
||||
|
|
@ -260,4 +260,4 @@ class CaptureAnnotations(View):
|
|||
|
||||
capture_obj.put_annotations(data_dict)
|
||||
|
||||
return jsonify(capture_obj.annotations)
|
||||
return capture_obj.annotations
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from labthings.server.view import View
|
|||
|
||||
from labthings.server.decorators import ThingProperty, Tag, doc_response
|
||||
|
||||
from flask import jsonify, request, abort
|
||||
from flask import request, abort
|
||||
import logging
|
||||
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ class SettingsProperty(View):
|
|||
Current microscope settings, including camera and stage
|
||||
"""
|
||||
microscope = find_component("org.openflexure.microscope")
|
||||
return jsonify(microscope.read_settings())
|
||||
return microscope.read_settings()
|
||||
|
||||
def put(self):
|
||||
"""
|
||||
|
|
@ -51,7 +51,7 @@ class NestedSettingsProperty(View):
|
|||
except KeyError:
|
||||
return abort(404)
|
||||
|
||||
return jsonify(value)
|
||||
return value
|
||||
|
||||
@doc_response(404, description="Settings key cannot be found")
|
||||
def put(self, route):
|
||||
|
|
@ -78,7 +78,7 @@ class StateProperty(View):
|
|||
Show current read-only state of the microscope
|
||||
"""
|
||||
microscope = find_component("org.openflexure.microscope")
|
||||
return jsonify(microscope.state)
|
||||
return microscope.state
|
||||
|
||||
|
||||
@Tag("properties")
|
||||
|
|
@ -96,7 +96,7 @@ class NestedStateProperty(View):
|
|||
except KeyError:
|
||||
return abort(404)
|
||||
|
||||
return jsonify(value)
|
||||
return value
|
||||
|
||||
|
||||
@ThingProperty
|
||||
|
|
@ -106,7 +106,7 @@ class ConfigurationProperty(View):
|
|||
Show current read-only state of the microscope
|
||||
"""
|
||||
microscope = find_component("org.openflexure.microscope")
|
||||
return jsonify(microscope.configuration)
|
||||
return microscope.configuration
|
||||
|
||||
|
||||
@Tag("properties")
|
||||
|
|
@ -124,4 +124,4 @@ class NestedConfigurationProperty(View):
|
|||
except KeyError:
|
||||
return abort(404)
|
||||
|
||||
return jsonify(value)
|
||||
return value
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue