Html file did not work for live streaming in django

In camera.py file

class VideoCamera(object):
    def __init__(self):
        self.video = cv2.VideoCapture(0)
        # Define the codec and create VideoWriter object
    def __del__(self):
        self.video.release()
    
    def get_frame(self):
        success, image = self.video.read()
        ret, jpeg = cv2.imencode('.jpg',image)
        return jpeg.tobytes()

**In view.py file **

def gen(camera):

    while True:
        frame = camera.get_frame()
        yield (b'--frame\r\n'
                b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n')


def video_feed(request):
    return StreamingHttpResponse(gen(VideoCamera()),
                    content_type='multipart/x-mixed-replace; boundary=frame')

** My url.py file**

tyurlpatterns = [
    path('live/',stream_views.video_feed,name='video_feed'),

And HTML file

{% extends 'blog/base.html' %}
{% block content %}
    <img src="{{ url 'video_feed' }}" alt="video_feed">
{%endblock content%}

here my html file is not work.It just run other file.Html file can't access this url . what i can do for solving this problem?

I expect my every frame continuously pass into my html page.

Back to Top