commit
cc21abe843
|
@ -5,13 +5,19 @@ from sanic import Sanic
|
||||||
from sanic import response
|
from sanic import response
|
||||||
from jinja2 import Environment, PackageLoader, select_autoescape
|
from jinja2 import Environment, PackageLoader, select_autoescape
|
||||||
|
|
||||||
|
import sys
|
||||||
|
# Enabling async template execution which allows you to take advantage
|
||||||
|
# of newer Python features requires Python 3.6 or later.
|
||||||
|
enable_async = sys.version_info >= (3, 6)
|
||||||
|
|
||||||
|
|
||||||
app = Sanic(__name__)
|
app = Sanic(__name__)
|
||||||
|
|
||||||
# Load the template environment with async support
|
# Load the template environment with async support
|
||||||
template_env = Environment(
|
template_env = Environment(
|
||||||
loader=PackageLoader('jinja_example', 'templates'),
|
loader=PackageLoader('jinja_example', 'templates'),
|
||||||
autoescape=select_autoescape(['html', 'xml']),
|
autoescape=select_autoescape(['html', 'xml']),
|
||||||
enable_async=True
|
enable_async=enable_async
|
||||||
)
|
)
|
||||||
|
|
||||||
# Load the template from file
|
# Load the template from file
|
||||||
|
|
Loading…
Reference in New Issue
Block a user