python jinja2 code example

Example 1: jinja2 python

<title>{% block title %}{% endblock %}</title>
<ul>
{% for user in users %}
  <li><a href="{{ user.url }}">{{ user.username }}</a></li>
{% endfor %}
</ul>

Example 2: jinja2

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class = "container">
      <h1>
        Hi my name is {{ name }}
      </h1>
    </div>
</body>
</html>

Example 3: jinja2

import flask 
from flask import Flask , render_templates

app = Flask(__name__)
@app.route("/")
def hi():
  name = "Your Name"
  return render_templates(index.html , name = name)

# The html code below this code is mine

Tags:

Misc Example