'''
在页面上面显示四大名著
'''
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 %}