Flask “send_from_directory” always sends files of one type as attachment

  Kiến thức lập trình

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.

New contributor

araujo2kg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT