Moved gen() into streams.py

This commit is contained in:
Joel Collins 2020-11-17 11:20:07 +00:00
parent 729f10170c
commit c9c29a7db4
2 changed files with 8 additions and 10 deletions

View file

@ -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":

View file

@ -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):