Open
Description
Make custom head
tag with meta
, title
, script
, and link
tags.
For example, it looks like the one below.
class Head(pydanctic.BaseModel, extra='forbid')
elements: list[AnyHeadElement]
def render_head_element(head: Head) -> str:
additional_tags: str = "\n".join([element in element in head.elements])
return f"""
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
{additional_tags}
<script type="module" crossorigin src="{_PREBUILT_CDN_URL}/index.js"></script>
<link rel="stylesheet" crossorigin href="{_PREBUILT_CDN_URL}/index.css">
</head>
"""
def prebuilt_html(head: Head):
"""
Returns a simple HTML page which includes the FastUI react frontend, loaded from https://www.jsdelivr.com/.
Arguments:
title: page title
Returns:
HTML string which can be returned by an endpoint to serve the FastUI frontend.
"""
# language=HTML
head: str = render_head_element(head=head)
return f"""\
<!doctype html>
<html lang="en">
{head}
<body>
<div id="root"></div>
</body>
</html>
"""
If it is reasonable, can I contribute as pull request?