How to run code after Flask send_file() or send_from_directory() How to run code after Flask send_file() or send_from_directory() flask flask

How to run code after Flask send_file() or send_from_directory()


You can't. While send_file streams the file using Flask when using the dev server, it may (and really should for performance) use the web server (nginx, apache, etc.) and X-SendFile in production. Since the web server is beyond the control of the application, you're out of luck.