solution_122d.py

#!/usr/bin/python
# ================================================================
# start/end webpage support function/data
# ================================================================

start_of_web_page = '''\
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="author" content="{author}" />
<link rel="stylesheet" href="{css1}" />
<link rel="stylesheet" href="{css2}" />
<link rel="icon"          href="favicon.png" type="image/png" />
<link rel="shortcut icon" href="favicon.png" type="image/png" />
<title>{pagetitle}</title>
{style}
</head>
<body>
<header>
<center>{headertitle}</center>
</header>
<div class="indent12">
<p>'''

end_of_web_page = '''\
</p>
</div>
<footer>
<modate>Last Modified: {today}</modate>
</footer>
</body>
</html>'''

mystyle='''\
<style>
modate { font-size: 0.8em; margin-left: 12px; }
div.box
{
  display: inline-block;
  font-size:1.1em;
  font-family: monospace;
  background-color: white;
  border: 2px solid #000;
  padding: 10px;
}
</style>'''

def fstr(web_page,params):
    return web_page.format(**params)

# ---------------------------------------------------------------
# ---- main
# ---------------------------------------------------------------

if __name__ == '__main__':

    import datetime as dt

    print()
    x = fstr(start_of_web_page,
        {'pagetitle'  :'Page Title',
         'author'     :'George',
         'css1'       :'style1.css',
         'css2'       :'style2.css',
         'style'      :mystyle,
         'headertitle':'header Title'})

    print(x)

    print()
    x = fstr(end_of_web_page,
        {'today': dt.datetime.now().strftime("%B %d,%Y %I:%M:%S%p")})
    print(x,end='')