Script Development / Response Data DFF.RESP
The return value of a function, in addition to directly returning strings or JSON as before, can be controlled in detail using DFF.RESP(...)
.
Parameter | Type | Required / Default | Description |
---|---|---|---|
data |
str/dict/list | Required | Specifies the data to be returned |
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 the HTTP response headers (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 downloads the data as a file When this parameter is specified, the content_type parameter is ignored |
If allow_304
is enabled, allowing browser 304 caching can improve interface performance. However, it may also cause the client to fail to get the latest content from the interface in time due to caching.
When the download
parameter is specified, the system will automatically fill in 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 |
|