When building web-apps using Flask, it is quite easy to write messy codes jumping over files in different languages (ex- python, JavaScript, HTML — ‘if i may’)
In order to directly import the python variables and functions to HTML file, Flask supports Jinja Template — a modern and designer-friendly templating language for Python.
Jinja’s Basic Structure
{{ ... }} : delimiter for variables or expressions{% ... %} : delimiter for statements such as if or for{# ... #} : comment
So let’s jump into the code.
Print one-hundred “Hello, World” on the browser using Jinja Template.
- Using Jinja — for-statement
2. Using Jinja — variable and expression
Implementing Jina Template on HTML file enables to directly use python code on web-development thus enhances the efficiency of the code structure.