Script Development / Response File DFF.RESP_FILE
When returning a file that already exists in the resource directory, use DFF.RESP_FILE(...). Fill file_path directly with the resource-relative path; there is no need to call DFF.RSRC(...) first.
Parameters
| Parameter | Type | Required / Default | Description |
|---|---|---|---|
file_path |
str | Required | Resource directory relative path |
status_code |
int | 200 |
HTTP status code |
headers |
dict | None |
Additional response headers |
allow_304 |
bool | False |
Whether to allow browsers to use 304 cache |
auto_delete |
bool | False |
Whether to automatically delete the disk file after the response is sent |
download |
bool / str | True |
True downloads using the original file name; False attempts to open in the browser; a string specifies the download name |
The system automatically fills in Content-Type based on the file extension.
| Example | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 | |
When constructing DFF.RESP_FILE(...), the file must already exist, and the resolved path must be within the configured resource root directory. auto_delete=True deletes the file after the response is sent; do not enable this option for files that are shared or need to be reused.
Large files generated at runtime should first be written to the resource directory and then returned with this method; temporary files can use auto_delete=True. Binary output must be written to a binary file; do not pass binary bytes to DFF.RESP(...) or DFF.RESP_LARGE_DATA(...).