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

Moved gen() into streams.py

parent 729f1017
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -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":
+8 −1
Original line number Diff line number Diff line
@@ -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):