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.
Parameters
| Name | Type | Description |
|---|---|---|
| directory | `os.PathLike[str] | str` |
| path | `os.PathLike[str] | str` |
| kwargs | t.Any | Additional arguments to pass to the underlying :func:send_file call, such as 'as_attachment'. |
Returns
| Type | Description |
|---|---|
Response | A response object containing the file content, or raises a 404 NotFound error if the file does not exist. |