diff --git a/.gitignore b/.gitignore
index 483de3d..bf0e1ea 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,5 @@
+__pycache__/
+*.py[cod]
+*$py.class
 .venv
 .idea
diff --git a/bin/person_detection.sh b/bin/person_detection.sh
index dacdda6..97fab3b 100755
--- a/bin/person_detection.sh
+++ b/bin/person_detection.sh
@@ -2,4 +2,6 @@
 args="$@"
 source .venv/bin/activate
 source /opt/intel/openvino/bin/setupvars.sh
-python3 person_detection/person_detection.py -d CPU -m models/intel/person-detection-retail-0013/FP32/person-detection-retail-0013.xml $args
+#python3 person_detection/person_detection.py -d CPU -m models/intel/person-detection-retail-0013/FP32/person-detection-retail-0013.xml $args
+python3 person_detection/app.py -d CPU -m models/intel/person-detection-retail-0013/FP32/person-detection-retail-0013.xml $args
+
diff --git a/person_detection/app.py b/person_detection/app.py
new file mode 100644
index 0000000..1b1fbde
--- /dev/null
+++ b/person_detection/app.py
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+from importlib import import_module
+import os
+from flask import Flask, render_template, Response
+from argparse import ArgumentParser, SUPPRESS
+
+# import camera driver
+if os.environ.get('CAMERA'):
+    Camera = import_module('camera_' + os.environ['CAMERA']).Camera
+else:
+    #from camera import Camera
+    from person_detection import Camera
+
+# Raspberry Pi camera module (requires picamera package)
+# from camera_pi import Camera
+
+app = Flask(__name__)
+
+
+@app.route('/')
+def index():
+    """Video streaming home page."""
+    return render_template('index.html')
+
+
+def gen(camera):
+    """Video streaming generator function."""
+    print("Video streaming generator function.")
+    while True:
+        frame = camera.get_frame()
+        yield (b'--frame\r\n'
+               b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
+
+
+@app.route('/video_feed')
+def video_feed():
+    """Video streaming route. Put this in the src attribute of an img tag."""
+    print("video_feed()", args)
+    camera = Camera(args)
+    print("Camera: ", camera)
+    return Response(gen(camera),
+                    mimetype='multipart/x-mixed-replace; boundary=frame')
+
+def build_argparser():
+    parser = ArgumentParser(add_help=False)
+    args = parser.add_argument_group('Options')
+    args.add_argument('-h', '--help', action='help', default=SUPPRESS, help='Show this help message and exit.')
+    args.add_argument("-m", "--model", help="Required. Path to an .xml file with a trained model.",
+                      required=True, type=str)
+    args.add_argument("-i", "--input",
+                      help="Required. Path to video file or image. 'cam' for capturing video stream from camera",
+                      required=True, type=str)
+    args.add_argument("-l", "--cpu_extension",
+                      help="Optional. Required for CPU custom layers. Absolute path to a shared library with the "
+                           "kernels implementations.", type=str, default=None)
+    args.add_argument("-pp", "--plugin_dir", help="Optional. Path to a plugin folder", type=str, default=None)
+    args.add_argument("-d", "--device",
+                      help="Optional. Specify the target device to infer on; CPU, GPU, FPGA, HDDL or MYRIAD is "
+                           "acceptable. The demo will look for a suitable plugin for device specified. "
+                           "Default value is CPU", default="CPU", type=str)
+    args.add_argument("--labels", help="Optional. Path to labels mapping file", default=None, type=str)
+    args.add_argument("-pt", "--prob_threshold", help="Optional. Probability threshold for detections filtering",
+                      default=0.5, type=float)
+    args.add_argument("-ns", help='No show output', action='store_true')
+
+    return parser
+
+if __name__ == '__main__':
+    args = build_argparser().parse_args()
+    app.run(host='0.0.0.0', threaded=True)
diff --git a/person_detection/base_camera.py b/person_detection/base_camera.py
new file mode 100644
index 0000000..96c148a
--- /dev/null
+++ b/person_detection/base_camera.py
@@ -0,0 +1,101 @@
+import time
+import threading
+try:
+    from greenlet import getcurrent as get_ident
+except ImportError:
+    try:
+        from thread import get_ident
+    except ImportError:
+        from _thread import get_ident
+
+
+class CameraEvent(object):
+    """An Event-like class that signals all active clients when a new frame is
+    available.
+    """
+    def __init__(self):
+        self.events = {}
+
+    def wait(self):
+        """Invoked from each client's thread to wait for the next frame."""
+        ident = get_ident()
+        if ident not in self.events:
+            # this is a new client
+            # add an entry for it in the self.events dict
+            # each entry has two elements, a threading.Event() and a timestamp
+            self.events[ident] = [threading.Event(), time.time()]
+        return self.events[ident][0].wait()
+
+    def set(self):
+        """Invoked by the camera thread when a new frame is available."""
+        now = time.time()
+        remove = None
+        for ident, event in self.events.items():
+            if not event[0].isSet():
+                # if this client's event is not set, then set it
+                # also update the last set timestamp to now
+                event[0].set()
+                event[1] = now
+            else:
+                # if the client's event is already set, it means the client
+                # did not process a previous frame
+                # if the event stays set for more than 5 seconds, then assume
+                # the client is gone and remove it
+                if now - event[1] > 5:
+                    remove = ident
+        if remove:
+            del self.events[remove]
+
+    def clear(self):
+        """Invoked from each client's thread after a frame was processed."""
+        self.events[get_ident()][0].clear()
+
+
+class BaseCamera(object):
+    thread = None  # background thread that reads frames from camera
+    frame = None  # current frame is stored here by background thread
+    last_access = 0  # time of last client access to the camera
+    event = CameraEvent()
+
+    def __init__(self):
+        """Start the background camera thread if it isn't running yet."""
+        if BaseCamera.thread is None:
+            BaseCamera.last_access = time.time()
+
+            # start background frame thread
+            BaseCamera.thread = threading.Thread(target=self._thread)
+            BaseCamera.thread.start()
+
+            # wait until frames are available
+            while self.get_frame() is None:
+                time.sleep(0)
+
+    def get_frame(self):
+        """Return the current camera frame."""
+        BaseCamera.last_access = time.time()
+
+        # wait for a signal from the camera thread
+        BaseCamera.event.wait()
+        BaseCamera.event.clear()
+
+        return BaseCamera.frame
+
+    def frames():
+        """"Generator that returns frames from the camera."""
+        raise RuntimeError('Must be implemented by subclasses.')
+
+    def _thread(self):
+        """Camera background thread."""
+        frames_iterator = self.frames()
+        for frame in frames_iterator:
+            BaseCamera.frame = frame
+            BaseCamera.event.set()  # send signal to clients
+            time.sleep(0)
+
+            # if there hasn't been any clients asking for frames in
+            # the last 10 seconds then stop the thread
+            if time.time() - BaseCamera.last_access > 10:
+                frames_iterator.close()
+                print('Stopping camera thread due to inactivity.')
+                break
+        BaseCamera.thread = None
diff --git a/person_detection/person_detection.py b/person_detection/person_detection.py
index 702f9f8..6f56a6f 100644
--- a/person_detection/person_detection.py
+++ b/person_detection/person_detection.py
@@ -13,6 +13,7 @@
 from argparse import ArgumentParser, SUPPRESS
 from imutils import build_montages
 from openvino.inference_engine import IECore
+from base_camera import BaseCamera
 
 
 def build_argparser():
@@ -40,152 +41,164 @@
     return parser
 
 
-def main():
-    log.basicConfig(format="[ %(levelname)s ] %(message)s", level=log.INFO, stream=sys.stdout)
-    args = build_argparser().parse_args()
-    model_xml = args.model
-    model_bin = os.path.splitext(model_xml)[0] + ".bin"
+class Camera(BaseCamera):
 
-    # Read IR
-    log.info("Reading IR...")
-    net = IECore().read_network(model=model_xml, weights=model_bin)
+    def __init__(self, args):
+        log.basicConfig(format="[ %(levelname)s ] %(message)s", level=log.INFO, stream=sys.stdout)
+        model_xml = args.model
+        model_bin = os.path.splitext(model_xml)[0] + ".bin"
 
-    assert len(net.inputs.keys()) == 1, "Demo supports only single input topologies"
-    assert len(net.outputs) == 1, "Demo supports only single output topologies"
-    input_blob = next(iter(net.inputs))
-    out_blob = next(iter(net.outputs))
+        # Read IR
+        log.info("Reading IR...")
+        net = IECore().read_network(model=model_xml, weights=model_bin)
 
-    log.info("Loading IR to the plugin...")
-    exec_net = IECore().load_network(network=net, device_name=args.device, num_requests=2)
-    # Read and pre-process input image
-    n, c, h, w = net.inputs[input_blob].shape
-    del net
-    if args.input == 'cam':
-        input_stream = 0
-    elif args.input == 'gstreamer':
-        # gst rtp sink
-        input_stream = 'udpsrc port=5000 caps = " application/x-rtp, encoding-name=JPEG,payload=26" ! rtpjpegdepay ! decodebin ! videoconvert ! appsink'
-        #input_stream = 'udpsrc port=5000 caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" ! rtph264depay ! decodebin ! videoconvert ! appsink'
-    else:
-        input_stream = args.input
-        assert os.path.isfile(args.input), "Specified input file doesn't exist"
+        assert len(net.inputs.keys()) == 1, "Demo supports only single input topologies"
+        assert len(net.outputs) == 1, "Demo supports only single output topologies"
+        self.input_blob = next(iter(net.inputs))
+        self.out_blob = next(iter(net.outputs))
 
-    if input_stream == 'gstreamer':
-        cap = cv2.VideoCapture(input_stream, cv2.CAP_GSTREAMER)
-    else:
-        cap = cv2.VideoCapture(input_stream)
-
-    if args.labels:
-        with open(args.labels, 'r') as f:
-            labels_map = [x.strip() for x in f]
-    else:
-        labels_map = None
-
-    cur_request_id = 0
-    next_request_id = 1
-
-    log.info("Starting inference in async mode...")
-    log.info("To switch between sync and async modes press Tab button")
-    log.info("To stop the demo execution press Esc button")
-
-    # Async doesn't work if True
-    # Request issues = Runtime Error: [REQUEST BUSY]
-    is_async_mode = False
-    #is_async_mode = True
-    render_time = 0
-    ret, frame = cap.read()
-
-    frameList = []
-
-    print("To close the application, press 'CTRL+C' or any key with focus on the output window")
-
-    while True:
-        if is_async_mode:
-            ret, next_frame = cap.read()
+        log.info("Loading IR to the plugin...")
+        self.exec_net = IECore().load_network(network=net, device_name=args.device, num_requests=2)
+        # Read and pre-process input image
+        self.n, self.c, self.h, self.w = net.inputs[self.input_blob].shape
+        del net
+        if args.input == 'cam':
+            input_stream = 0
+        elif args.input == 'gstreamer':
+            # gst rtp sink
+            input_stream = 'udpsrc port=5000 caps = " application/x-rtp, encoding-name=JPEG,payload=26" ! rtpjpegdepay ! decodebin ! videoconvert ! appsink'
+            #input_stream = 'udpsrc port=5000 caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" ! rtph264depay ! decodebin ! videoconvert ! appsink'
         else:
-            ret, frame = cap.read()
-        if not ret:
-            break
-        initial_w = cap.get(3)
-        initial_h = cap.get(4)
+            input_stream = args.input
+            assert os.path.isfile(args.input), "Specified input file doesn't exist"
 
-        # Main sync point:
-        # in the truly Async mode we start the NEXT infer request, while waiting for the CURRENT to complete
-        # in the regular mode we start the CURRENT request and immediately wait for it's completion
-        inf_start = time.time()
-        if is_async_mode:
-            if ret:
-                in_frame = cv2.resize(next_frame, (w, h))
-                in_frame = in_frame.transpose((2, 0, 1))  # Change data layout from HWC to CHW
-                in_frame = in_frame.reshape((n, c, h, w))
-                exec_net.start_async(request_id=next_request_id, inputs={input_blob: in_frame})
+        if input_stream == 'gstreamer':
+            self.cap = cv2.VideoCapture(input_stream, cv2.CAP_GSTREAMER)
         else:
-            if ret:
-                in_frame = cv2.resize(frame, (w, h))
-                in_frame = in_frame.transpose((2, 0, 1))  # Change data layout from HWC to CHW
-                in_frame = in_frame.reshape((n, c, h, w))
-                exec_net.start_async(request_id=cur_request_id, inputs={input_blob: in_frame})
+            self.cap = cv2.VideoCapture(input_stream)
 
-        if exec_net.requests[cur_request_id].wait(-1) == 0:
-            inf_end = time.time()
-            det_time = inf_end - inf_start
+        if args.labels:
+            with open(args.labels, 'r') as f:
+                self.labels_map = [x.strip() for x in f]
+        else:
+            self.labels_map = None
 
-            # Parse detection results of the current request
-            res = exec_net.requests[cur_request_id].outputs[out_blob]
+        self.args = args
 
-            for obj in res[0][0]:
-                # Draw only objects when probability more than specified threshold
-                if obj[2] > args.prob_threshold:
-                    xmin = int(obj[3] * initial_w)
-                    ymin = int(obj[4] * initial_h)
-                    xmax = int(obj[5] * initial_w)
-                    ymax = int(obj[6] * initial_h)
-                    class_id = int(obj[1])
-                    # Draw box and label\class_id
-                    color = (min(class_id * 12.5, 255), min(class_id * 7, 255), min(class_id * 5, 255))
-                    cv2.rectangle(frame, (xmin, ymin), (xmax, ymax), color, 2)
-                    det_label = labels_map[class_id] if labels_map else str(class_id)
-                    cv2.putText(frame, det_label + ' ' + str(round(obj[2] * 100, 1)) + ' %', (xmin, ymin - 7),
-                                cv2.FONT_HERSHEY_COMPLEX, 0.6, color, 1)
-                    print('Object detected, class_id:', class_id, 'probability:', obj[2], 'xmin:', xmin, 'ymin:', ymin,
-                          'xmax:', xmax, 'ymax:', ymax)
+        super(Camera, self).__init__()
 
-            # Draw performance stats
-            inf_time_message = "Inference time: Not applicable for async mode" if is_async_mode else \
-                "Inference time: {:.3f} ms".format(det_time * 1000)
-            render_time_message = "OpenCV rendering time: {:.3f} ms".format(render_time * 1000)
-            if is_async_mode:
-                async_mode_message = "Async mode is on. Processing request {}".format(cur_request_id)
+    def __del__(self):
+        self.cap.release()
+        cv2.destroyAllWindows()
+
+    def frames(self):
+        cur_request_id = 0
+        next_request_id = 1
+
+        log.info("Starting inference in async mode...")
+        log.info("To switch between sync and async modes press Tab button")
+        log.info("To stop the demo execution press Esc button")
+
+        # Async doesn't work if True
+        # Request issues = Runtime Error: [REQUEST BUSY]
+        self.is_async_mode = False
+        #is_async_mode = True
+        render_time = 0
+        ret, frame = self.cap.read()
+
+        frameList = []
+
+        print("To close the application, press 'CTRL+C' or any key with focus on the output window")
+
+        while True:
+            if self.is_async_mode:
+                ret, next_frame = self.cap.read()
             else:
-                async_mode_message = "Async mode is off. Processing request {}".format(cur_request_id)
+                ret, frame = self.cap.read()
+            if not ret:
+                break
+            initial_w = self.cap.get(3)
+            initial_h = self.cap.get(4)
 
-            cv2.putText(frame, inf_time_message, (15, 15), cv2.FONT_HERSHEY_COMPLEX, 0.5, (200, 10, 10), 1)
-            cv2.putText(frame, render_time_message, (15, 30), cv2.FONT_HERSHEY_COMPLEX, 0.5, (10, 10, 200), 1)
-            cv2.putText(frame, async_mode_message, (10, int(initial_h - 20)), cv2.FONT_HERSHEY_COMPLEX, 0.5,
-                        (10, 10, 200), 1)
+            # Main sync point:
+            # in the truly Async mode we start the NEXT infer request, while waiting for the CURRENT to complete
+            # in the regular mode we start the CURRENT request and immediately wait for it's completion
+            inf_start = time.time()
+            if self.is_async_mode:
+                if ret:
+                    in_frame = cv2.resize(next_frame, (self.w, self.h))
+                    in_frame = in_frame.transpose((2, 0, 1))  # Change data layout from HWC to CHW
+                    in_frame = in_frame.reshape((self.n, self.c, self.h, self.w))
+                    self.exec_net.start_async(request_id=next_request_id, inputs={self.input_blob: in_frame})
+            else:
+                if ret:
+                    in_frame = cv2.resize(frame, (self.w, self.h))
+                    in_frame = in_frame.transpose((2, 0, 1))  # Change data layout from HWC to CHW
+                    in_frame = in_frame.reshape((self.n, self.c, self.h, self.w))
+                    self.exec_net.start_async(request_id=cur_request_id, inputs={self.input_blob: in_frame})
 
-        render_start = time.time()
+            if self.exec_net.requests[cur_request_id].wait(-1) == 0:
+                inf_end = time.time()
+                det_time = inf_end - inf_start
 
-        if not args.ns:
-            if ret:
-                cv2.imshow("Detection results", frame)
-            render_end = time.time()
-            render_time = render_end - render_start
+                # Parse detection results of the current request
+                res = self.exec_net.requests[cur_request_id].outputs[self.out_blob]
 
-        if is_async_mode:
-            cur_request_id, next_request_id = next_request_id, cur_request_id
+                for obj in res[0][0]:
+                    # Draw only objects when probability more than specified threshold
+                    if obj[2] > self.args.prob_threshold:
+                        xmin = int(obj[3] * initial_w)
+                        ymin = int(obj[4] * initial_h)
+                        xmax = int(obj[5] * initial_w)
+                        ymax = int(obj[6] * initial_h)
+                        class_id = int(obj[1])
+                        # Draw box and label\class_id
+                        color = (min(class_id * 12.5, 255), min(class_id * 7, 255), min(class_id * 5, 255))
+                        cv2.rectangle(frame, (xmin, ymin), (xmax, ymax), color, 2)
+                        det_label = self.labels_map[class_id] if self.labels_map else str(class_id)
+                        cv2.putText(frame, det_label + ' ' + str(round(obj[2] * 100, 1)) + ' %', (xmin, ymin - 7),
+                                    cv2.FONT_HERSHEY_COMPLEX, 0.6, color, 1)
+                        print('Object detected, class_id:', class_id, 'probability:', obj[2], 'xmin:', xmin, 'ymin:', ymin,
+                              'xmax:', xmax, 'ymax:', ymax)
 
-            frame = next_frame
-        key = cv2.waitKey(1)
-        if key == 27:
-            break
-        if 9 == key:
-            is_async_mode = not is_async_mode
-            log.info("Switched to {} mode".format("async" if is_async_mode else "sync"))
+                # Draw performance stats
+                inf_time_message = "Inference time: Not applicable for async mode" if self.is_async_mode else \
+                    "Inference time: {:.3f} ms".format(det_time * 1000)
+                render_time_message = "OpenCV rendering time: {:.3f} ms".format(render_time * 1000)
+                if self.is_async_mode:
+                    async_mode_message = "Async mode is on. Processing request {}".format(cur_request_id)
+                else:
+                    async_mode_message = "Async mode is off. Processing request {}".format(cur_request_id)
 
-    cap.release()
-    cv2.destroyAllWindows()
+                cv2.putText(frame, inf_time_message, (15, 15), cv2.FONT_HERSHEY_COMPLEX, 0.5, (200, 10, 10), 1)
+                cv2.putText(frame, render_time_message, (15, 30), cv2.FONT_HERSHEY_COMPLEX, 0.5, (10, 10, 200), 1)
+                cv2.putText(frame, async_mode_message, (10, int(initial_h - 20)), cv2.FONT_HERSHEY_COMPLEX, 0.5,
+                            (10, 10, 200), 1)
+
+            render_start = time.time()
+
+            yield cv2.imencode('.jpg', frame)[1].tobytes()
+
+            if not self.args.ns:
+                if ret:
+                    cv2.imshow("Detection results", frame)
+                render_end = time.time()
+                render_time = render_end - render_start
+
+            if self.is_async_mode:
+                cur_request_id, next_request_id = next_request_id, cur_request_id
+
+                frame = next_frame
+            key = cv2.waitKey(1)
+            if key == 27:
+                break
+            if 9 == key:
+                self.is_async_mode = not self.is_async_mode
+                log.info("Switched to {} mode".format("async" if self.is_async_mode else "sync"))
 
 
 if __name__ == '__main__':
-    sys.exit(main() or 0)
+    args = build_argparser().parse_args()
+    camera = Camera(args)
+    camera.frames()
+    del camera
diff --git a/person_detection/templates/index.html b/person_detection/templates/index.html
new file mode 100644
index 0000000..26ab1e8
--- /dev/null
+++ b/person_detection/templates/index.html
@@ -0,0 +1,9 @@
+<html>
+  <head>
+    <title>Person Detection - Aether Edge Application</title>
+  </head>
+  <body>
+    <h1>Person Detection - Aether Edge Application</h1>
+    <img src="{{ url_for('video_feed') }}">
+  </body>
+</html>
diff --git a/requirements.txt b/requirements.txt
index 9d6d5da..e07847b 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,2 +1,8 @@
+click==8.0.1
+Flask==2.0.1
 imutils==0.5.4
+itsdangerous==2.0.1
+Jinja2==3.0.1
+MarkupSafe==2.0.1
 numpy==1.19.5
+Werkzeug==2.0.1
