Python Forum

Full Version: Flask, send_from_directory not working : solved
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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 ?
The clue is in the name of the function: the first argument should be the directory (see the docs).
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 !