pythonimageflaskattachmentwebp

Flask "send_from_directory" always sends files of one type as attachment


I am trying to return images to this route with send_from_directory, every image type works, it displays the img in the browser correctly, but .webp images don't? If i access this route with an .webp image as argument the browser always downloads it directly as if the "as_attachment" parameter was set to true, which is not.

@bp.route("/<imagename>", methods=["GET"]) def get_image(imagename): return send_from_directory(current_app.config["IMAGES_DIR"], imagename, as_attachment=False)

Tried with every other image file extension, everyone worked normally displaying the image in the browser.


Solution

  • Apparently the problem was the image itself, even though it is a normal .webp image for some reason it behaves differently from others.