| 1234567891011121314151617181920 | from aiohttp import webfrom mako.lookup import TemplateLookupfrom mako.template import Templatefrom mako.exceptions import TopLevelLookupExceptiontemplates = TemplateLookup(directories=['./templates'], module_directory='./__templates_cache__')def render_template(name, status=200, **data):  try:    text = templates.get_template(f'{name}.html').render_unicode(**data)  except TopLevelLookupException:    text = '404: template not found.'    status = 404  response = web.Response(text=text,                          status=status,                          charset = 'utf-8',                          content_type = 'text/html')  return response
 |