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

Switched away from using JSONify

parent 4fffa1fc
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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")
+2 −2
Original line number Diff line number Diff line
@@ -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
+0 −1
Original line number Diff line number Diff line
from openflexure_microscope.devel import (
    JsonResponse,
    request,
    jsonify,
    taskify,
    update_task_progress,
)
+2 −4
Original line number Diff line number Diff line
@@ -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
+3 −3
Original line number Diff line number Diff line
@@ -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
Loading