Skip to content

Script Development / Function Page DFF.FUNC_PAGE

To facilitate function invocation, DataFlux Func can automatically generate directly callable operation pages for functions, eliminating the need for front-end development.

1. Example

In a function decorated with @DFF.API, returning a FUNC_PAGE object enables the "Function Page" feature.

Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
@DFF.API('Greeting')
def greeting(name='dear'):
    return f'Hello, {name}'

@DFF.API('Plus')
def plus(x, y):
    return float(x) + float(y)

@DFF.API('Func Page')
def func_page():
    page = DFF.FUNC_PAGE()

    page.set_title('My Func Page')
    page.add_html('h1', 'Welcome to my Func Page!')
    page.add_html('hr')
    page.add_html('p', 'You can call Func directly from this page')

    page.add_func('test__func_page.greeting')
    page.add_func('test__func_page.plus')

    return page

After creating a "Function API" for func_page, open it in a browser:

Page styles may change with version updates

As DataFlux Func versions are updated, the style of function pages generated by the same code may vary.

func-page.png

2. FUNC_PAGE Object

The API for FUNC_PAGE is as follows:

.set_title(...)

Set the page title:

Parameter Type Required / Default Description
title str Required Title content
Example
1
page.set_title('My Func Page')

.add_html(...)

Add an HTML block:

Parameter Type Required / Default Description
tag str Required HTML tag, such as "h1", "p", "span", "hr"
text str Tag content
Example
1
page.add_html('p', 'Hello, World')

.add_func(...)

Add a function block:

Parameter Type Required / Default Description
func_id str Required Function ID, such as "demo__test.run"
Example
1
page.add_func('demo__test.run')