0
0
Flaskframework~5 mins

File download responses in Flask - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What Flask function is commonly used to send files for download?
The send_file() function is used in Flask to send files to the client, enabling file downloads.
Click to reveal answer
beginner
How do you specify the filename that the user will see when downloading a file in Flask?
You use the download_name parameter in send_file() to set the filename shown to the user.
Click to reveal answer
beginner
What parameter in send_file() forces the browser to download the file instead of displaying it?
Setting as_attachment=True in send_file() tells the browser to download the file as an attachment.
Click to reveal answer
intermediate
Why is it important to set the correct MIME type when sending a file in Flask?
The MIME type tells the browser what kind of file it is. Setting it correctly helps the browser handle or display the file properly.
Click to reveal answer
intermediate
How can you send a file stored in memory (like a BytesIO object) for download in Flask?
You can pass the in-memory file object directly to send_file() along with as_attachment=True and a download_name.
Click to reveal answer
Which Flask function is used to send a file to the client for download?
Asend_file()
Bsend_response()
Cdownload_file()
Dfile_send()
What parameter do you set to True in send_file() to force a file download?
Aas_attachment=True
Bdownload=True
Cforce_download=True
Dattachment=True
How do you specify the filename the user sees when downloading a file in Flask?
Aname
Bfile_name
Cfilename
Ddownload_name
If you want to send a PDF file for download, which MIME type should you set?
Atext/plain
Bimage/png
Capplication/pdf
Dapplication/json
Can you use send_file() to send a file stored in memory (like BytesIO)?
ANo, only files on disk can be sent
BYes, by passing the in-memory file object
COnly if you convert it to a string first
DOnly if you save it temporarily to disk
Explain how to send a file for download in Flask including setting the filename and forcing download.
Think about the parameters in send_file() that control download behavior.
You got /3 concepts.
    Describe why setting the correct MIME type is important when sending files in Flask.
    Consider how browsers decide what to do with received files.
    You got /3 concepts.