Complete the code to import the function used to send files in Flask.
from flask import Flask, [1]
The send_file function is used to send files from the server to the client in Flask.
Complete the route function to send a file named 'example.txt' from the 'uploads' folder.
from flask import send_file @app.route('/download') def download(): return send_file('[1]')
The file path must include the folder where the file is stored, here 'uploads/example.txt'.
Fix the error in the code to correctly send a file with a custom download name.
return send_file('uploads/report.pdf', [1]='monthly_report.pdf')
In Flask 2.0+, the correct argument to set the download filename is download_name.
Fill both blanks to send a file as an attachment with the correct MIME type.
return send_file('uploads/image.png', [1]=True, [2]='image/png')
as_attachment=True forces download, and mimetype sets the file type.
Fill all three blanks to serve an uploaded file securely using 'send_from_directory'.
from flask import send_from_directory @app.route('/uploads/<filename>') def uploaded_file(filename): return send_from_directory([1], [2], [3]=True)
send_from_directory needs the folder, the filename, and as_attachment=True to serve files for download.