send_from_directory
Send a file from within a directory using :func:send_file.
def send_from_directory(
directory: os.PathLike[str] | str,
path: os.PathLike[str] | str,
**kwargs: t.Any
) - > Response
Send a file from within a directory using :func:send_file. This is a secure way to serve files from a folder, such as static files or uploads. Uses :func:~werkzeug.security.safe_join to ensure the path coming from the client is not maliciously crafted to point outside the specified directory. If the final path does not point to an existing regular file, raises a 404 :exc:~werkzeug.exceptions.NotFound error.
Parameters
| Name | Type | Description |
|---|---|---|
| directory | `os.PathLike[str] | str` |
| path | `os.PathLike[str] | str` |
| **kwargs | t.Any | Additional keyword arguments to pass to the underlying send_file function, such as as_attachment or download_name. |
Returns
| Type | Description |
|---|---|
Response | A response object containing the file content, formatted by the underlying send_file utility. |