Python Forum
Flask, send_from_directory not working : solved
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Flask, send_from_directory not working : solved
#1
Question 
Hi everyone,

here my simple test code :

def download():
	try:
		return send_from_directory('C:\\original.jpg', filename='original.jpg', as_attachment=True)
	
	except FileNotFoundError:
		abort(404)
No matter what I try I get in the Internet browser

Quote:Not Found

The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

and this message is not even triggered by the except :/

Any ideas ?
Reply
#2
The clue is in the name of the function: the first argument should be the directory (see the docs).
SpongeB0B likes this post
Reply
#3
Thank you @ndc85430 !!

it's was so simple ! I'm ashamed.... I'll try to find this tutorial where I have found this bad example/mistake !
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question [Solved] Running Gunicorn with flask.... SpongeB0B 1 504 Jun-27-2022, 03:09 PM
Last Post: SpongeB0B
Thumbs Up Flask do not accept sub-folder in Template ?! : Solved SpongeB0B 2 1,899 Jan-15-2021, 08:09 AM
Last Post: ndc85430
  My flask website not working properly Aggam 2 1,225 Nov-03-2020, 09:53 AM
Last Post: Aggam
  Flask, Posgresql - Multiple requests are not working bmaganti 5 1,690 Feb-20-2020, 03:02 PM
Last Post: bmaganti
  Flask Streaming not working on IIS Windows Revencu 0 1,492 Nov-09-2019, 10:31 PM
Last Post: Revencu
  flask app to save images locally when deployed on heroku not working Prince_Bhatia 1 4,297 Feb-20-2019, 11:59 PM
Last Post: snippsat
  Serving mixed filenames with send_from_directory() errors out. nikos 0 1,442 Sep-20-2018, 03:11 AM
Last Post: nikos
  Cannot serve file with send_from_directory nikos 2 1,756 Sep-19-2018, 09:25 PM
Last Post: nikos

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020