Skip to content

Script Development / Func Page DFF.FUNC_PAGE

DFF.FUNC_PAGE() is used to return an auto-generated simple function invocation page, suitable for combining a few Funcs into an operation page without the need to separately develop a frontend page.

Example

Simply return the page object in a Func decorated with @DFF.API(...):

Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
@DFF.API('Greeting')
def greeting(name='World'):
    return f'Hello, {name}!'

@DFF.API('Func Page')
def func_page():
    page = DFF.FUNC_PAGE()
    page.set_title('My Func Page')
    page.add_html('h1', 'My Func Page', color='#409EFF', bold=True)
    page.add_func(greeting, default_kwargs={'name': 'User'})
    page.add_split()
    page.add_space(20)
    return page

After creating a Func API for func_page, you can access it by opening it in a browser. The page styling may change with DataFlux Func version updates.

func-page.png

API

Method Description
page = DFF.FUNC_PAGE() Creates a page object; the title defaults to the current Func title
page.set_title(title) Sets the page title
page.add_html(tag, text=None, indent=None, space=None, color=None, bold=False, italic=False, style=None, buttons=None) Adds an HTML block with optional styles and buttons; tag can be h1, p, span, hr, etc.
page.add_func(func, default_kwargs=None) Adds a callable Func block with optional default arguments
page.add_split() Adds a separator block
page.add_space(size=10) Adds vertical spacing

The func parameter of add_func(...) and the func of each button in buttons can be either a Func ID or a function decorated with @DFF.API(...). default_kwargs must match the parameters of the target Func.

When rendering the response, Func blocks and buttons are resolved from published Func metadata. Unknown or unpublished Func IDs cannot be resolved and may cause page rendering to fail, so every referenced Func must already be published.

Returning the page grants temporary invocation capability

When the page contains callable Funcs, the system creates a temporary browser authorization Token limited to the resolved Func IDs. Only add Funcs that page visitors should actually execute to the page, and treat returning this page as granting temporary invocation capability.

style, button data, and displayed text are all part of page content; do not insert untrusted HTML or secret values. Complex interactive pages should return self-implemented HTML or be used together with resource files.