source
get_app_config_schema
get_app_config_schema (app_title:str='FastHTML Application',
config_dir:str='configs', server_port:int=5000,
themes_enum:Optional[List[str]]=None,
themes_enum_names:Optional[List[str]]=None,
default_theme:Optional[str]=None,
include_theme:bool=True, **extra_properties)
Generate a customizable application configuration schema.
| app_title |
str |
FastHTML Application |
Default application title |
| config_dir |
str |
configs |
Default configuration directory |
| server_port |
int |
5000 |
Default server port |
| themes_enum |
Optional |
None |
Optional list of theme values |
| themes_enum_names |
Optional |
None |
Optional list of theme display names |
| default_theme |
Optional |
None |
Default theme value |
| include_theme |
bool |
True |
Whether to include theme selection |
| extra_properties |
VAR_KEYWORD |
|
|
| Returns |
Dict |
|
JSON Schema for application configuration |
# Example: Create a basic app config schema
basic_schema = get_app_config_schema(
app_title="My FastHTML App",
server_port=5001,
include_theme=False
)
print(f"Schema name: {basic_schema['name']}")
print(f"Schema title: {basic_schema['title']}")
print(f"Default app_title: {basic_schema['properties']['app_title']['default']}")
print(f"Default server_port: {basic_schema['properties']['server_port']['default']}")
print(f"Has theme property: {'theme' in basic_schema['properties']}")
Schema name: general
Schema title: Application Configuration
Default app_title: My FastHTML App
Default server_port: 5001
Has theme property: False
# Example: Create schema with DaisyUI themes
try:
from cjm_fasthtml_daisyui.core.themes import DaisyUITheme
theme_schema = get_app_config_schema(
app_title="My Themed App",
themes_enum=[theme.value for theme in DaisyUITheme],
themes_enum_names=[theme.value.title() for theme in DaisyUITheme],
default_theme=DaisyUITheme.LIGHT.value,
include_theme=True
)
print(f"Has theme property: {'theme' in theme_schema['properties']}")
print(f"Default theme: {theme_schema['properties']['theme']['default']}")
print(f"Has onclick_save: {'onclick_save' in theme_schema}")
except ImportError:
print("cjm_fasthtml_daisyui not available - skipping theme example")
Has theme property: True
Default theme: light
Has onclick_save: True