Added LabThing decorators
This commit is contained in:
parent
c1da678439
commit
6b99873d53
1 changed files with 9 additions and 12 deletions
|
|
@ -6,23 +6,24 @@ from openflexure_microscope.common.labthings_core.utilities import (
|
||||||
create_from_path,
|
create_from_path,
|
||||||
)
|
)
|
||||||
|
|
||||||
from openflexure_microscope.common.flask_labthings.find import find_device
|
from openflexure_microscope.common.flask_labthings.find import find_component
|
||||||
from openflexure_microscope.common.flask_labthings.resource import Resource
|
from openflexure_microscope.common.flask_labthings.resource import Resource
|
||||||
|
from openflexure_microscope.common.flask_labthings.decorators import doc_response, ThingProperty
|
||||||
|
|
||||||
from flask import jsonify, request, abort, Response
|
from flask import Response
|
||||||
import logging
|
|
||||||
|
|
||||||
|
|
||||||
|
@ThingProperty
|
||||||
class MjpegStream(Resource):
|
class MjpegStream(Resource):
|
||||||
"""
|
"""
|
||||||
Real-time MJPEG stream from the microscope camera
|
Real-time MJPEG stream from the microscope camera
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@doc_response(200, mimetype="multipart/x-mixed-replace")
|
||||||
def get(self):
|
def get(self):
|
||||||
"""
|
"""
|
||||||
MJPEG stream from the microscope camera
|
MJPEG stream from the microscope camera
|
||||||
"""
|
"""
|
||||||
microscope = find_device("org.openflexure.microscope")
|
microscope = find_component("org.openflexure.microscope")
|
||||||
# Restart stream worker thread
|
# Restart stream worker thread
|
||||||
microscope.camera.start_worker()
|
microscope.camera.start_worker()
|
||||||
|
|
||||||
|
|
@ -31,22 +32,18 @@ class MjpegStream(Resource):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ThingProperty
|
||||||
class SnapshotStream(Resource):
|
class SnapshotStream(Resource):
|
||||||
"""
|
"""
|
||||||
Single JPEG snapshot from the camera stream
|
Single JPEG snapshot from the camera stream
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@doc_response(200, description="Snapshot taken", mimetype="image/jpeg")
|
||||||
def get(self):
|
def get(self):
|
||||||
"""
|
"""
|
||||||
Single snapshot from the camera stream
|
Single snapshot from the camera stream
|
||||||
|
|
||||||
.. :quickref: Streams; Camera snapshot
|
|
||||||
|
|
||||||
:>header Accept: image/jpeg
|
|
||||||
:>header Content-Type: image/jpeg
|
|
||||||
:status 200: stream active
|
|
||||||
"""
|
"""
|
||||||
microscope = find_device("org.openflexure.microscope")
|
microscope = find_component("org.openflexure.microscope")
|
||||||
# Restart stream worker thread
|
# Restart stream worker thread
|
||||||
microscope.camera.start_worker()
|
microscope.camera.start_worker()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue