While FastAPI is focused on the APIs, it is still entirely possible to serve HTML pages as well. The code will be almost identical to the preceding code—except that our functions need to return this HTML code.
The most common approach to generate HTML in Python is to use the Jinja2 templating engine—that way, you write the template as an HTML code with some injections of Python and later render them by feeding it with the variables; Jinja will execute and hide the injections, returning the resultant page.
For the sake of building a simple example, however, we will use another package: VDOM, which allows us to generate VDOMs (short for Virtual Document Object Models) in Python and then convert them into HTML. Flask is great for smaller projects, but not for large and complex applications.
To separate this page from the main API, let's create...