'''
在页面上面显示四大名著
'''
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)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>四大名著</title>
</head>
<body>
<table border="1" cellpadding="0">
<tr>
<th>书名</th>
<th>作者</th>
</tr>
{% for book in books %}
<tr>
<td>{{book.book_name}}</td>
<td>{{book.author}}</td>
</tr>
{% endfor %}
</table>
</body>
</html>
點擊查看更多內容
2人點贊
評論
評論
共同學習,寫下你的評論
評論加載中...
作者其他優(yōu)質文章
正在加載中
感謝您的支持,我會繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦