mako template renderer for aiohttp.web (http server for asyncio)
Project description
mako template renderer for aiohttp.web based on aiohttp_jinja2. Library has almost same api and support python 3.5 (PEP492) syntax. It is used in aiohttp_debugtoolbar.
Example
import asyncio
import aiohttp_mako
from aiohttp import web
@aiohttp_mako.template('index.html')
async def func(request):
return {'head': 'aiohttp_mako', 'text': 'Hello World!'}
async def init(loop):
app = web.Application(loop=loop)
lookup = aiohttp_mako.setup(app, input_encoding='utf-8',
output_encoding='utf-8',
default_filters=['decode.utf8'])
template = """<html><body><h1>${head}</h1>${text}</body></html>"""
lookup.put_string('index.html', template)
app.router.add_route('GET', '/', func)
handler = app.make_handler()
srv = await loop.create_server(handler, '127.0.0.1', 8080)
print("Server started at http://127.0.0.1:8080")
return srv, handler
loop = asyncio.get_event_loop()
srv, handler = loop.run_until_complete(init(loop))
try:
loop.run_forever()
except KeyboardInterrupt:
loop.run_until_complete(handler.finish_connections())
License
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.1.0.tar.gz
(7.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aiohttp-mako-0.1.0.tar.gz.
File metadata
- Download URL: aiohttp-mako-0.1.0.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
618b621a1d124ecc6a8a50fa4eb5f8f86fe9abfb7a28b5303a02da7a5ae37530
|
|
| MD5 |
ebefa9c1c86e3c542628703d20db0e6d
|
|
| BLAKE2b-256 |
9654b06ba9e342349fa0091fad3e8dbbcf9683c493478c5b9ab6ef8542d22f1e
|
File details
Details for the file aiohttp_mako-0.1.0-py3-none-any.whl.
File metadata
- Download URL: aiohttp_mako-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef5918527fd60f6bd706d27879fe82bce3513664e69d44204b6b8d1e21c9c9f2
|
|
| MD5 |
2c059f89c154a2bbc02f608539c94807
|
|
| BLAKE2b-256 |
90d9e5f93747f0995bf162a24768898dfe6730a1d6c2806cdc56140bc18d42bd
|