You can download this code by clicking the button below.
This code is now available for download.
This function creates a simple Sanic web application that uses the Jinja2 template engine to render HTML pages.
Technology Stack : Sanic, Jinja2
Code Type : Web Application
Code Difficulty : Intermediate
def random_sanic_function():
import random
from sanic import Sanic, response
from sanic_jinja2 import SanicJinja2
app = Sanic(name='Random Sanic App')
jinja = SanicJinja2(app)
@app.route('/')
async def index(request):
return await jinja.render_async('index.html', request, title="Home Page")
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8000)