register_function
Register a Python function to be used by the Pages system. Regular functions become async JavaScript functions in the browser, callable via POST. A function named __render__ is special: it is called on GET requests and must return an HTML string.
Parameters
| Name | Description | Type | Default |
|---|---|---|---|
| func (required) | The function to register. Must have JSON-serializable parameters and return value. Callable: The original function (unchanged), allowing use as a decorator. python from abstra.pages import register_function @register_function def get_data(query: str): return \{"results": [...]\} @register_function def __render__(): return "<h1>My Page</h1><script>get_data('test').then(console.log)</script>" | Callable | None |
Return Value
Callable