Loading openflexure_microscope/api/__init__.py 0 → 100644 +1 −0 Original line number Diff line number Diff line from . import utilities openflexure_microscope/api/templates/index.html→openflexure_microscope/api/templates/index_v0.html +0 −0 File moved. View file openflexure_microscope/api/templates/index_v1.html 0 → 100644 +9 −0 Original line number Diff line number Diff line <html> <head> <title>Video Streaming Demonstration</title> </head> <body> <h1>Video Streaming Demonstration</h1> <img src="{{ url_for('stream') }}"> </body> </html> openflexure_microscope/api/utilities.py 0 → 100644 +15 −0 Original line number Diff line number Diff line def parse_payload(request): """Convert request to JSON. Will eventually handle error-checking.""" # TODO: Handle invalid JSON payloads state = request.get_json() return state 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') openflexure_microscope/api/app.py→openflexure_microscope/api/v0.py +2 −17 Original line number Diff line number Diff line Loading @@ -11,34 +11,19 @@ from flask import ( import numpy as np from openflexure_microscope.api.utilities import parse_payload, gen from openflexure_microscope.camera.pi import StreamingCamera app = Flask(__name__) cam = StreamingCamera() def parse_payload(request): """Convert request to JSON. Will eventually handle error-checking.""" # TODO: Handle invalid JSON payloads state = request.get_json() return state 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') @app.route('/') def index(): """Video streaming home page.""" cam.start_worker() # Start the stream return render_template('index.html') return render_template('index_v0.html') @app.route('/stream') Loading Loading
openflexure_microscope/api/__init__.py 0 → 100644 +1 −0 Original line number Diff line number Diff line from . import utilities
openflexure_microscope/api/templates/index.html→openflexure_microscope/api/templates/index_v0.html +0 −0 File moved. View file
openflexure_microscope/api/templates/index_v1.html 0 → 100644 +9 −0 Original line number Diff line number Diff line <html> <head> <title>Video Streaming Demonstration</title> </head> <body> <h1>Video Streaming Demonstration</h1> <img src="{{ url_for('stream') }}"> </body> </html>
openflexure_microscope/api/utilities.py 0 → 100644 +15 −0 Original line number Diff line number Diff line def parse_payload(request): """Convert request to JSON. Will eventually handle error-checking.""" # TODO: Handle invalid JSON payloads state = request.get_json() return state 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')
openflexure_microscope/api/app.py→openflexure_microscope/api/v0.py +2 −17 Original line number Diff line number Diff line Loading @@ -11,34 +11,19 @@ from flask import ( import numpy as np from openflexure_microscope.api.utilities import parse_payload, gen from openflexure_microscope.camera.pi import StreamingCamera app = Flask(__name__) cam = StreamingCamera() def parse_payload(request): """Convert request to JSON. Will eventually handle error-checking.""" # TODO: Handle invalid JSON payloads state = request.get_json() return state 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') @app.route('/') def index(): """Video streaming home page.""" cam.start_worker() # Start the stream return render_template('index.html') return render_template('index_v0.html') @app.route('/stream') Loading