from flask import Flask
from flask import render_template
app = Flask(name)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/user/<name>')
def user(name):
mydict={'key':'key'}
return render_template('user.html', name=name,mydict=mydict)
if name == 'main':
app.run()
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>Hello, {{ name }}!</h1>
<h2>HELLO,{{ mydict['key']|capitalize }}</h2>
<h2>HELLO,{{ mydict['key']|upper }}</h2>
{% if user %}
Hello, {{ user }}!
{% else %}
Hello, Stranger!
{% endif %}
<ul>
{% for comment in comments %}
<li>{{ comment }}</li>
{% endfor %}
</ul>
{% macro render_comment(comment) %}
<li>{{ comment }}</li>
{% endmacro %}
<ul>
{% for comment in comments %}
{{ render_comment(comment) }}
{% endfor %}
</ul>
</body>
</html>
{% include 'common.html' %}
<html>
<head>
{% block head %}
<title>{% block title %}{% endblock %} - My Application</title>
{% endblock %}
</head>
<body>
{% block body %}
{% endblock %}
</body>
</html>
{% extends "base.html" %}
{% block title %}Index{% endblock %}
{% block head %}
{{ super() }}
<style>
</style>
{% endblock %}
{% block body %}
<h1>Hello, World!</h1>
{% endblock %}