django redirect when in HttpStreamingResponse

55 Views Asked by At

i am developing a django application, which scans the barcodes from camera feed using pyzbar and displays the data

def scan_barcode(request):
        return StreamingHttpResponse(
            scan_feed(),
            content_type="multipart/x-mixed-replace; boundary=frame"
        )
    

this is view i am using to view my camera feed

def scan_feed():
    global qr_data
    while True:
        frame, qr_data = scanner(camera)
        if qr_data:
            print(qr_data)
            print("redirecting....")
            return redirect("/profile")
  
        yield (b"--frame\r\n" b"Content-Type: image/jpeg\r\n\r\n" + frame + b"\r\n\r\n")

this is scan_feed function where i am validating the qrdata and wants to redirect to another page

<img src="http://localhost:8000/scan_barcode">

this is the html code

i am accesing the camera feed, i can see the camera feed and recognise the qrcode and printing it successfully but unable to redirect to next page any suggestions on above code PS: i am new to Django Framework Thanks in advance

0

There are 0 best solutions below