Thanks to @user459872 and @globglogabgalab, the enclosed code is less error prune and here are the two missing lines of code to get the generated HTML
from fasthtml import common as fh
from fastcore.xml import to_xml
my_var=fh.P('This is a simple example!')
print(to_xml(my_var))