def build_html_document(body, title=None):
 title_html = ('<h1>{0}</h1>\n'.format(title) if title else '')
 html = ['<html>', '<head>', '<title>{title}</title>'.format(title=title), '<style>', '\n  body { font-size:10pt }\n  table { font-size:10pt;border-width:none;\n          border-spacing:0px;border-color:#F8F8F8;border-style:solid }\n  th, td { padding:2px;vertical-align:top;\n           border-width:1px;border-color:#F8F8F8;border-style:solid; }\n  th { font-weight:bold;text-align:left;font-family:times }\n  th { color:#666666 }\n  a, a.toggle:link, a.toggle:visited {\n      background-color:#FFFFFF;color:#000099 }\n  a.toggle:hover, a.toggle:active {\n      color:#FFFFFF;background-color:#000099 }\n</style></head>', '<body>', title_html, body, '</body>', '</html>']
 return '\n'.join(html)

def build_html_document ( body , title = None ) : title_html = ( '<h1>{0}</h1>\n' . format ( title ) if title else '' ) html = [ '<html>' , '<head>' , '<title>{title}</title>' . format ( title = title ) , '<style>' , '\n  body { font-size:10pt }\n  table { font-size:10pt;border-width:none;\n          border-spacing:0px;border-color:#F8F8F8;border-style:solid }\n  th, td { padding:2px;vertical-align:top;\n           border-width:1px;border-color:#F8F8F8;border-style:solid; }\n  th { font-weight:bold;text-align:left;font-family:times }\n  th { color:#666666 }\n  a, a.toggle:link, a.toggle:visited {\n      background-color:#FFFFFF;color:#000099 }\n  a.toggle:hover, a.toggle:active {\n      color:#FFFFFF;background-color:#000099 }\n</style></head>' , '<body>' , title_html , body , '</body>' , '</html>' ] return '\n' . join ( html )
produces the html document wrapper for a text/html response .