uf.base#
Core functionality for uf - UI Fast.
This module provides the main mk_rjsf_app function that bridges:
Functions → HTTP services (via qh)
HTTP services → Web UI forms (via ju.rjsf)
Following the “convention over configuration” philosophy, it provides sensible defaults while allowing customization where needed.
Functions
|
Create an RJSF-backed web app from a list of functions. |
Classes
|
Wrapper class for uf applications. |
- class uf.base.UfApp(funcs, **mk_rjsf_app_kwargs)[source]#
Bases:
objectWrapper class for uf applications.
Provides a higher-level interface with additional conveniences beyond the raw qh app.
- app#
The underlying qh/bottle/fastapi app
- function_specs#
FunctionSpecStore for function metadata
- funcs#
Dictionary mapping function names to callables
- uf.base.mk_rjsf_app(funcs, *, config=None, input_trans=None, output_trans=None, rjsf_config=None, ui_schema_factory=None, param_to_prop_type=None, page_title='Function Interface', function_display_names=None, custom_css=None, rjsf_theme='default', add_ui=True, **qh_kwargs)[source]#
Create an RJSF-backed web app from a list of functions.
This is the main entry point for uf. It combines qh’s HTTP service generation with ju’s RJSF form generation to create a complete web interface for your functions.
- Parameters:
funcs (
Union[Iterable[Callable],Mapping[str,Callable]]) – Iterable of callables to expose via web UI – functions, partials, callable instances (named byuf.specs.name_of_func) – or a mapping{name: callable}to name them yourself. The name is the route and the key of the form specconfig (
Optional[Any]) – Optional qh.AppConfig for HTTP service configurationinput_trans (
Optional[Callable]) – Optional input transformation function for qhoutput_trans (
Optional[Callable]) – Optional output transformation function for qhrjsf_config (
Optional[dict]) – Optional configuration dict for RJSF generationui_schema_factory (
Optional[Callable]) – Optional callable to customize UI schemaparam_to_prop_type (
Optional[Callable]) – Optional callable to map parameters to typespage_title (
str) – Title for the web interfacefunction_display_names (
Optional[Mapping]) – Optional mapping to override function namescustom_css (
Optional[str]) – Optional custom CSS for the web interfacerjsf_theme (
str) – RJSF theme to use (‘default’, ‘material-ui’, etc.)add_ui (
bool) – Whether to add UI routes (set False for API-only)**qh_kwargs – Additional keyword arguments passed to qh.mk_app
- Returns:
HTTP endpoints for each function
RJSF-based web interface (if add_ui=True)
API routes for function specs
- Return type:
A configured web application (bottle or FastAPI app) with
Example
>>> def add(x: int, y: int) -> int: ... '''Add two numbers''' ... return x + y ... >>> def greet(name: str) -> str: ... '''Greet a person''' ... return f"Hello, {name}!" ... >>> app = mk_rjsf_app([add, greet]) >>> # app.run() # Start the web server
Example with customization:
>>> from uf import mk_rjsf_app, RjsfFieldConfig >>> >>> def send_email(to: str, subject: str, body: str): ... '''Send an email''' ... pass ... >>> app = mk_rjsf_app( ... [send_email], ... page_title="Email Sender", ... custom_css="body { background: #f0f0f0; }", ... )