title: Capture video stream flask
body: <p>I have created a simple live video stream from the raspberry camera. It looks like this</p>
  
  <p><br/></p>
  
  <p><strong>server.py</strong></p>
  
  <pre><code>from flask import Flask
  from flask import render_template
  from flask import Response
  
  import cv2
  
  app = Flask(__name__)
  
  @app.route('/')
  def index():
      return render_template('index.html')
  
  @app.route('/video_feed')
  def video_feed():
      return Response(gen(), mimetype='multipart/x-mixed-replace; boundary=frame')
  
  def gen():
      camera = cv2.VideoCapture(0)
  
      while True:
          ret, img = camera.read()
  
          if ret:
              frame = cv2.imencode('.jpg', img)[1].tobytes()
              yield (b'--frame\r\n'b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
          else:
              break
  
  app.run(host='192.168.0.241', port=7070, debug=True)
  </code></pre>
  
  <p><br/></p>
  
  <p><strong>index.html</strong></p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;PiCamera stream&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;Streaming&lt;/h1&gt;
          &lt;img src="{{ url_for('video_feed') }}"&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><br/></p>
  
  <p>Everything works correct, I enter <code>http://&lt;raspberry_ip&gt;:&lt;port&gt;</code> in the browser and I can see the video.</p>
  
  <p><br/></p>
  
  <p>Right now I need to create mobile app for watching this video, however I am struggling how to do it. Is there a way to capture video stream in iOS app?</p>