Serving static files in Flask with Content-Length in HTTP response header
If you use send_file() with a filename (not a file object), Flask will automatically set the Content-Length header for you.
send_from_directory() uses send_file() with a filename, so you are set there.
Do make sure you are using Flask 0.10 or newer; the header code was added in that version.
I am writing a small Python Flask application which allow people download file from my server. These files will be served by Python, not web server like Nginx or Apache.
I tried to use send_from_directory() and send_file() and I can download my file but there was no file-size because it was missed the Content-Length filed in the Header.
How can I added the header when I use send_from_directory() or send_file(). Or are there any other better way to do this.
Thank you.