flask render_template示例

from flask import Flask,request,render_template
app = Flask(__name__,static_url_path='',template_folder='')
@app.route('/')
def a():
    student=[(1,2,3),(4,5,6)]
    return render_template("template.html",student=student)
if __name__=='__main__':
    app.run(host='0.0.0.0',port=80)

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>template</title>
</head>
<body>

<div>{{ student }}</div>
<table border="1xp">
    {% for s in student %}
        <tr>
            <td>{{ s[0] }}</td>
            <td>{{ s[1] }}</td>
            <td>{{ s[2] }}</td>
        </tr>
    {% endfor %}
</table>
</body>
</html>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章