flask_if语句详解

  • Post author:
  • Post category:其他


from flask import Flask,render_template

app = Flask(__name__)
app.config.update({
    'DEBUG':True,
    'TEMPLATES_AUTO_RELOAD':True
})

@app.route('/')
def index():
    context={
        'username':'了',
        'age':17

    }



return


render_template(

‘index.html’


,

**context)

#html

<body>
    {% if username=='知了'%}
        <p>知了课堂</p>
    {% else %}
       <p>我不是知了课堂</p>
    {% endif %}
    {% if age>=18 %}
        <p>你可以进入网吧</p>
    {% else %}
        <P>未成年人</P>
    {% endif %}
</body>




版权声明:本文为qq_27110607原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。