how to write a sentence in html jinja

Solutions on MaxInterview for how to write a sentence in html jinja by the best coders in the world

showing results for - "how to write a sentence in html jinja"
Elias
17 Apr 2020
1Python:
2from flask import Flask, render_template
3app = Flask(__name__)
4
5@app.route("/")
6def template_test():
7    return render_template('template.html', my_string="Wheeeee!", my_list=[0,1,2,3,4,5])
8
9if __name__ == '__main__':
10    app.run(debug=True)
11
12
13HTML:
14<!DOCTYPE html>
15<html>
16  <head>
17    <title>Flask Template Example</title>
18    <meta name="viewport" content="width=device-width, initial-scale=1.0">
19    <link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" media="screen">
20    <style type="text/css">
21      .container {
22        max-width: 500px;
23        padding-top: 100px;
24      }
25    </style>
26  </head>
27  <body>
28    <div class="container">
29      <p>My string: {{my_string}}</p>
30      <p>Value from the list: {{my_list[3]}}</p>
31      <p>Loop through the list:</p>
32      <ul>
33        {% for n in my_list %}
34        <li>{{n}}</li>
35        {% endfor %}
36      </ul>
37    </div>
38    <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
39    <script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
40  </body>
41</html>