首页 > IT职业 > IT生活 > flask 显示四大名著
'''
在页面上面显示四大名著
'''
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def index():
books = [
{
'book_name': '西游记',
'author': '吴承恩'
},
{
'book_name': '红楼梦',
'author': '曹雪芹'
},
{
'book_name': '水浒传',
'author': '施耐庵'
},
{
'book_name': '三国演义',
'author': '罗贯中'
}
]
return render_template('index.html', books=books)
if __name__ == "__main__":
app.run(debug=True)
四大名著
书名
作者
{% for book in books %}
{{book.book_name}}
{{book.author}}
{% endfor %}
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4687/viewspace-2808336/ ,如需转载,请注明出处,否则将追究法律责任。