Skip to main content

mako template renderer for aiohttp.web (http server for asyncio)

Project description

mako template renderer for aiohttp.web based on aiohttp_jinja2. Library supports almost same api. It is used in aiohttp_debugtoolbar.


import asyncio
import aiohttp_mako
from aiohttp import web

def func(request):
    return {'head': 'aiohttp_mako', 'text': 'Hello World!'}

def init(loop):
    app = web.Application(loop=loop)
    lookup = aiohttp_mako.setup(app, input_encoding='utf-8',
    template = """<html><body><h1>${head}</h1>${text}</body></html>"""
    template_bug = """<html><body><h1>${head}</h1>${text}</body></html>"""

    lookup.put_string('index.html', template)
    lookup.put_string('bug.html', template_bug)

    app.router.add_route('GET', '/', func)

    handler = app.make_handler()
    srv = yield from loop.create_server(handler, '', 8080)
    print("Server started at")
    return srv, handler

loop = asyncio.get_event_loop()
srv, handler = loop.run_until_complete(init(loop))
except KeyboardInterrupt:


aiohttp_mako is offered under the Apache 2 license.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiohttp_mako-0.0.1.tar.gz (7.1 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page