Forums

Internal server error when trying to show images

I have an app in Flask that is working perfectly fine in my computer, when I tried to run it in pythonanywhere, I get a "500 internal server error". The HTML source is like this: <img src="{{ url_for('video_feed', id=id )}}" The python code:

@app.route("/video_feed/<id>", methods=['GET']) def video_feed(): global indexes, playPause # return the response generated along with the specific media # type (mime type) return Response(video_player(id), mimetype = "multipart/x-mixed-replace; boundary=frame")

The function video_player()

def video_player(id): global lock

while True:
    with lock:

        (flag, encodedImage) = cv2.imencode(".jpg", marco[Clientes[id].nroFrame])
        yield(b'--frame\r\n' b'Content-Type: image/jpeg\r\n\r\n' + bytearray(encodedImage) + b'\r\n')

Any ideas??

First, go to your Web app settings page and check if you have properly set up static files mappings (in section "Static files"). Also, you might want to look at our help page concerning this issue.

Thank you Pafk, I already checked just in case, but the thing is that the images are not in files but in an array...

What do you see in your logs? (link to logs is available on the "Web" page on PythonAnywhere)

Thanks! I'm new to this and didn't know about this and was really helpful!