【Python】Web学习笔记_flask(7)——Jinja2模板(1)

Jinja2是基于python的模板引擎,功能类似于PHP的amarty、J2ee的Freemarker和velocity,完全支持Unicode,并具有集成的沙箱执行环境,Jinja2使用的事BSD协议,允许使用者修改和重新发布代码,也允许使用或在BSD代码上开发商业软件发布和销售。

渲染模板:




    
    
    
    



欢迎来到{{name}}

{{message}}


了解更多

执行关键代码:

from flask import Flask,url_for,redirect,render_template

app=Flask(__name__)
@app.route('/')
def index():
    name="abc"
    message="""
    qwertyuiopasdfghjklzxcvbnm
    """
    return render_template("index.html",name=name,message=message)


if __name__=='__main__':
    app.run(
        debug=True
        ,port=8000
    )

执行结果:

【Python】Web学习笔记_flask(7)——Jinja2模板(1)_第1张图片

 

你可能感兴趣的:(python,学习,笔记,flask,web,前端)