Script Development / Response Data DFF.RESP
In addition to directly returning strings or JSON as before, function return values can be controlled in detail using DFF.RESP(...).
| Parameter | Type | Required / Default | Description |
|---|---|---|---|
data |
str/dict/list | Required | Specifies the data to return. |
status_code |
int | 200 |
Specifies the response status code. |
content_type |
str | None |
Specifies the response body type, such as json, text, html, etc. |
headers |
dict | None |
Specifies HTTP response headers (there is no need to repeat Content-Type here). |
allow_304 |
bool | False |
When set to True, allows browser 304 caching. |
download |
str | False |
Specifies the download filename and serves the data as a file download. When this parameter is specified, the content_type parameter no longer takes effect. |
If allow_304 is enabled, allowing browser 304 caching can improve interface performance. However, it may also cause clients to fail to obtain the latest content from the interface in a timely manner due to caching.
After specifying the download parameter, the system will automatically fill the Content-Type based on the file extension, and the content_type parameter will be ignored.
Common use cases are as follows:
| Python | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |