Flask — Jinja Template

Ji Kim
2 min readMar 3, 2020

--

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.

  1. Using Jinja — for-statement
Jinja Template for-statement

2. Using Jinja — variable and expression

send variable from app.py
name variable as testString

Implementing Jina Template on HTML file enables to directly use python code on web-development thus enhances the efficiency of the code structure.

--

--

Ji Kim
0 Followers

alert(‘Striving to be better.’);