Skip to content

Script Development / Redirect DFF.REDIRECT

The return value of a function can be not only data or files, but also an HTTP redirect response.

Parameter Type Required / Default Value Description
url str Required Redirect URL

Common use cases are as follows:

The redirect address must include http:// or https://

Python
1
2
3
4
5
6
@DFF.API('Example 1')
def case_1():
    '''
    Redirect to Baidu
    '''
    return DFF.REDIRECT('http://www.baidu.com')

Query parameters should be properly URLEncoded

Python
1
2
3
4
5
6
7
8
import urllib.parse

@DFF.API('Example 2')
def case_2():
    '''
    Redirect to Baidu and search for 'Guance'
    '''
    return DFF.REDIRECT('http://www.baidu.com/s?wd=' + urllib.parse.quote('Guance'))