update,
This commit is contained in:
53
tunmnlu/task_1/Q5/flaskapp/templates/index.html
Normal file
53
tunmnlu/task_1/Q5/flaskapp/templates/index.html
Normal file
@@ -0,0 +1,53 @@
|
||||
{#- This is a Jinja template - Flask uses Jinja as its templating engine. Jinja
|
||||
will process this file looking for directives to define a template based on
|
||||
the passed-in variables. This template relies on the `table`, `header`, and
|
||||
`username` variables to be declared.
|
||||
|
||||
A Jinja directive will start with a "{%" and Jinja comments will begin with
|
||||
a "{#". Both are ended with the same symbol and the closing brace "}".
|
||||
|
||||
If a dash "-" is provided before the opening or closing symbol for a
|
||||
directive, Jinja will ignore all whitespace up to that side of the directive
|
||||
in the template. -#}
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Flask Example</title>
|
||||
<link rel="stylesheet" href="/static/style.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<table>
|
||||
<caption>
|
||||
<h1>Movies</h1>
|
||||
{#- Templates can output variables inside {{...}}, like below #}
|
||||
<small>Data wrangled by {{username}}</small>
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
{#- Templates can also iterate over variables, producing the contents
|
||||
of the template (between the "for" and the "endfor" directives) for
|
||||
each element in the specified collection #}
|
||||
{%- for col in header %}
|
||||
<th>{{ col }}</th>
|
||||
{%- endfor %}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{%- for row in table %}
|
||||
{#- It is also possible to add "if" statements, the contents of these
|
||||
templates (between the "if" and "endif" directives) are inserted only
|
||||
if the supplied statement evaluates to `True`.
|
||||
|
||||
The directive in the line below will only add the class "star-trek"
|
||||
if the title contains the string "Star Trek" exactly. #}
|
||||
<tr {%- if 'Star Trek' in row[1] %} class='star-trek' {%- endif %}>
|
||||
{%- for col in row %}
|
||||
<td>{{ col }}</td>
|
||||
{%- endfor %}
|
||||
</tr>
|
||||
{%- endfor -%}
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user