Streaming camera feed from mjpeg-streamer with Flask (Python)
Question: I'm trying to stream a webcam feed from mjpeg-streamer through flask in a
simple web app. My flask code has a simple piece of html, which otherwise
works, which I insert the following line into:

    
    
    <img src=”/?action=stream”/>
    

But the picture doesn't load. I've tried varying this with things like making
the source have localhost:8080 (mjpeg-streamers port), and I've had no luck.
I've seen that for images, they should be in your static folder, but that
doesn't quite seem to apply here.

What am I doing wrong?


Answer: This is likely due to the [Same-Origin
Policy](http://en.wikipedia.org/wiki/Same-origin_policy) in web browsers. I
assume you're running your flask application on port 5000, and your mjpeg-
streamer is running on port 8080. This fails because you're trying to import a
resource from another port.

If you setup apache or similar to front your application, you can proxy the
mjpeg-streamer so that everything is served from the same port, and the
browser will pickup the stream correctly.

