Script Development / Response Data DFF.RESP
The return value of the function, in addition to directly returning strings or JSON as before, can use DFF.RESP(...)
for detailed control.
Parameter | Type | Required / Default Value | 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 type of response body, 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 file name and sends the data as a file download After specifying this parameter, the content_type parameter will no longer take effect |
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 due to caching.
After specifying the download
parameter, the system will automatically fill in the Content-Type
based on the file extension, and the content_type
parameter will be ignored.
Common usage examples 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 |
|