Skip to main content

send_file

Send the contents of a file to the client.

def send_file(
path_or_file: os.PathLike[t.AnyStr] | str | t.IO[bytes],
mimetype: str | None = None,
as_attachment: bool = False,
download_name: str | None = None,
conditional: bool = True,
etag: bool | str = True,
last_modified: datetime | int | float | None = None,
max_age: None | (int | t.Callable[[str | None], int | None]) = None
) - > Response

Send the contents of a file to the client.

Parameters

NameTypeDescription
path_or_file`os.PathLike[t.AnyStr]str
mimetype`strNone` = None
as_attachmentbool = FalseIndicate to a browser that it should offer to save the file instead of displaying it.
download_name`strNone` = None
conditionalbool = TrueEnable conditional and range responses based on request headers. Requires passing a file path and environ.
etag`boolstr` = True
last_modified`datetimeint
max_age`None(int

Returns

TypeDescription
ResponseA response object containing the file data and appropriate HTTP headers for delivery.