From 38ee3022e5321146432885a5cc5a66dd29551ed2 Mon Sep 17 00:00:00 2001 From: Shroominic Date: Sun, 12 May 2024 09:11:45 -0600 Subject: [PATCH 1/2] Ability to add more meta tags e.g. for seo --- src/python-fastui/fastui/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python-fastui/fastui/__init__.py b/src/python-fastui/fastui/__init__.py index a9066bcb..1c87284f 100644 --- a/src/python-fastui/fastui/__init__.py +++ b/src/python-fastui/fastui/__init__.py @@ -33,6 +33,7 @@ def prebuilt_html( api_root_url: _t.Union[str, None] = None, api_path_mode: _t.Union[_t.Literal['append', 'query'], None] = None, api_path_strip: _t.Union[str, None] = None, + meta_extra: _t.List[str] = [], ) -> str: """ Returns a simple HTML page which includes the FastUI react frontend, loaded from https://www.jsdelivr.com/. @@ -47,7 +48,6 @@ def prebuilt_html( Returns: HTML string which can be returned by an endpoint to serve the FastUI frontend. """ - meta_extra = [] if api_root_url is not None: meta_extra.append(f'') if api_path_mode is not None: From b24b17c582ce83075df7b5665795f26419f1f7fa Mon Sep 17 00:00:00 2001 From: Shroominic Date: Thu, 16 May 2024 10:32:23 -0600 Subject: [PATCH 2/2] pass meta_extra by dict --- src/python-fastui/fastui/__init__.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/python-fastui/fastui/__init__.py b/src/python-fastui/fastui/__init__.py index 1c87284f..f747eaa5 100644 --- a/src/python-fastui/fastui/__init__.py +++ b/src/python-fastui/fastui/__init__.py @@ -33,7 +33,7 @@ def prebuilt_html( api_root_url: _t.Union[str, None] = None, api_path_mode: _t.Union[_t.Literal['append', 'query'], None] = None, api_path_strip: _t.Union[str, None] = None, - meta_extra: _t.List[str] = [], + meta_extra: _t.Dict[str, str] = {}, ) -> str: """ Returns a simple HTML page which includes the FastUI react frontend, loaded from https://www.jsdelivr.com/. @@ -44,17 +44,21 @@ def prebuilt_html( api_path_mode: whether to append the page path to the root API request URL, or use it as a query parameter, default is 'append'. api_path_strip: string to remove from the start of the page path before making the API request. + meta_extra: dictionary where the key is the name of the meta tag and the value is the content. Returns: HTML string which can be returned by an endpoint to serve the FastUI frontend. """ if api_root_url is not None: - meta_extra.append(f'') + meta_extra['fastui:APIRootUrl'] = api_root_url if api_path_mode is not None: - meta_extra.append(f'') + meta_extra['fastui:APIPathMode'] = api_path_mode if api_path_strip is not None: - meta_extra.append(f'') - meta_extra_str = '\n '.join(meta_extra) + meta_extra['fastui:APIPathStrip'] = api_path_strip + + meta_extra_str = '\n '.join( + f'' for name, content in meta_extra.items() + ) # language=HTML return f"""\