Py4Web HTML Helpers

Stephen Lukacs (2) iquanta.org/instruct/python

Hello World! Testing 1 2 3.. .
This is a test of the American Broadcast system. This is only a test.
The time on the server right now is: 2025-12-29 05:28:27.
Goto: py4web Book for help on py4web HTML helpers.

"""
reference: https://iquanta.org/instruct/python ::: Example 2, Web2Py HTML Helpers ::: Stephen Lukacs, Ph.D. ©2021-09-19

this is server-side code and is thus all executed on the server.  the client simply displays what the server serves to
it. py4web is python software on the server that serves up the web pages to the client web browsers through the internet.

py4web has a set of functions that allow HTML tags to be embedded in python code.  these are python functions with the
HTML designator and opening and closing parentheses, (), instead of less than and greater than, <>, html characters.
this example has to load those python functions into the code, as is shown with the python from...import... command,
or "from yatl.helpers import P, SPAN, CAT, A, TAG".

the py4web functions are then used in the server-side executed code which translates to <p>, paragraph, <span>, span of
text, <cat>, which is not an html markup but a py4web to help bring two sections together, <br>, new-line, and <a>, which
creates a clickable link the user can click on to go to a new page, or whatever.

the code also imports the datetime module into the example and the server serves up the date and time on the server to
display it on the client.  notice that the seconds will not update after the page is loaded.  this is a sign that the time
processing occurred on the server only once the server sent the page and not continually updated by the client processor.
"""
#single line or after inline comment, and real executable code now...
from yatl.helpers import P, SPAN, CAT, A, TAG
from datetime import datetime

BR = TAG['br/']
rtn = P(SPAN("Hello World!", _style="font-style:italic; font-weight:bold;"), " Testing 1 2 3.. .")
rtn.append(CAT(BR(), "This is a test of the American Broadcast system.  This is only a test."))
rtn.append(CAT(BR(), "The time on the server right now is: ", SPAN(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), _style="font-weight:bold;"), "."))
rtn.append(CAT(BR(), "Goto: ", A("py4web Book", _href="https://py4web.com/_documentation/static/en/chapter-10.html", _target="py4web"), " for help on py4web HTML helpers."))
"""
where the P(), SPAN(), and BR() are py4web html functions, CAT() allows concatenation of html tags, and _style is
py4web's way of adding additional attributes to the html tag.  "_style" is the CSS inline style attribute with its value.
"""