From c9c29a7db4b00d0d1214e24f7e916f0a82ba003a Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Tue, 17 Nov 2020 11:20:07 +0000 Subject: [PATCH] Moved gen() into streams.py --- openflexure_microscope/api/utilities/__init__.py | 9 --------- openflexure_microscope/api/v2/views/streams.py | 9 ++++++++- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/openflexure_microscope/api/utilities/__init__.py b/openflexure_microscope/api/utilities/__init__.py index 7c12b2a9..8297cebc 100644 --- a/openflexure_microscope/api/utilities/__init__.py +++ b/openflexure_microscope/api/utilities/__init__.py @@ -24,15 +24,6 @@ def blueprint_name_for_module(module_name, api_ver=2, suffix=""): return f"v{api_ver}_{bp_name}_blueprint{suffix}" -def gen(camera): - """Video streaming generator function.""" - while True: - # the obtained frame is a jpeg - frame = camera.get_frame() - - yield (b"--frame\r\n" b"Content-Type: image/jpeg\r\n\r\n" + frame + b"\r\n") - - def get_bool(get_arg): """Convert GET request argument string to a Python bool""" if get_arg == "true" or get_arg == "True" or get_arg == "1": diff --git a/openflexure_microscope/api/v2/views/streams.py b/openflexure_microscope/api/v2/views/streams.py index 4e415936..c703ed3f 100644 --- a/openflexure_microscope/api/v2/views/streams.py +++ b/openflexure_microscope/api/v2/views/streams.py @@ -2,7 +2,14 @@ from flask import Response from labthings import find_component from labthings.views import PropertyView -from openflexure_microscope.api.utilities import gen + +def gen(camera): + """Video streaming generator function.""" + while True: + # the obtained frame is a jpeg + frame = camera.get_frame() + + yield (b"--frame\r\n" b"Content-Type: image/jpeg\r\n\r\n" + frame + b"\r\n") class MjpegStream(PropertyView):