Flask learning (two)-Jinji2 template engine

Project structure:
Insert picture description here

app.py

from flask import Flask, render_template

app = Flask(__name__)


@app.route('/')
def hello_world():
    url_str = 'https://www.baidu.com'
    return render_template('index.html', url_str = url_str)


if __name__ == '__main__':
    app.run(host='192.168.235.128', port=5000, debug=True)

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>学习</h1>
{
    
    {
    
     url_str }}
</body>
</html>

run:
Insert picture description here

operation result:
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_34663267/article/details/111875751