Jinja2 support for bareasgi
Project description
# bareASGI-jinja2
Jinja2 support for [bareASGI](http://github.com/rob-blackbourn/bareasgi) (read the [documentation](https://bareasgi-jinja2.readthedocs.io/en/latest/))
## Usage
Try the following.
```python
from typing import Mapping, Any
import jinja2
import os.path
import uvicorn
from bareasgi import Application
import bareasgi_jinja2
here = os.path.abspath(os.path.dirname(__file__))
@bareasgi_jinja2.template('example1.html')
async def http_request_handler(scope, info, matches, content):
return {'name': 'rob'}
app = Application()
env = jinja2.Environment(
loader=jinja2.FileSystemLoader(os.path.join(here, 'templates')),
autoescape=jinja2.select_autoescape(['html', 'xml']),
enable_async=True
)
bareasgi_jinja2.add_jinja2(app, env)
app.http_router.add({'GET'}, '/example1', http_request_handler)
uvicorn.run(app, port=9010)
```
Jinja2 support for [bareASGI](http://github.com/rob-blackbourn/bareasgi) (read the [documentation](https://bareasgi-jinja2.readthedocs.io/en/latest/))
## Usage
Try the following.
```python
from typing import Mapping, Any
import jinja2
import os.path
import uvicorn
from bareasgi import Application
import bareasgi_jinja2
here = os.path.abspath(os.path.dirname(__file__))
@bareasgi_jinja2.template('example1.html')
async def http_request_handler(scope, info, matches, content):
return {'name': 'rob'}
app = Application()
env = jinja2.Environment(
loader=jinja2.FileSystemLoader(os.path.join(here, 'templates')),
autoescape=jinja2.select_autoescape(['html', 'xml']),
enable_async=True
)
bareasgi_jinja2.add_jinja2(app, env)
app.http_router.add({'GET'}, '/example1', http_request_handler)
uvicorn.run(app, port=9010)
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bareasgi_jinja2-1.0.1.tar.gz
(3.1 kB
view hashes)
Built Distribution
Close
Hashes for bareasgi_jinja2-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 632c6d3cc3ae5b8ae13740e181f193bd560668b350c69a548a674666541b65a5 |
|
MD5 | 6effb96de63e15b7c5c8192a35091599 |
|
BLAKE2b-256 | dcab18e6ccad1d0dad251265e6c5103808ec0b2746b522bbc3f8c8e0685312a7 |