摘要: 文档结构 header.html 1 <style> 2 .nav ul { 3 overflow: hidden; 4 } 5 6 .nav ul li { 7 float: left; 8 margin: 0 20px; 9 } 10 </style> 11 <nav class="nav"> 阅读全文
posted @ 2023-06-01 15:23 jason2018 阅读(5) 评论(0) 推荐(0) 编辑
摘要: 父模板 base.html 1 <!DOCTYPE html> 2 <html lang="en"> 3 4 <head> 5 <meta charset="UTF-8"> 6 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 7 <meta 阅读全文
posted @ 2023-05-31 10:31 jason2018 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 宏 forms.html 1 {% macro input(name, value="",type="text") %} 2 <input type="{{ type }}" value="{{ value | escape }}" name="{{ name }}"> 3 {% endmacro 阅读全文
posted @ 2023-05-31 08:55 jason2018 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 调用 1 @app.route('/for') 2 def for_statement(): 3 books = [{ 4 'title': '三国演义', 5 'author': '罗贯中', 6 'price': 100 7 }, 8 { 9 'title': '水浒传', 10 'author 阅读全文
posted @ 2023-05-29 14:49 jason2018 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 调用 1 @app.route('/if') 2 def if_statement(): 3 age = 18 4 return render_template('if.html', age=age) if.html 1 <!DOCTYPE html> 2 <html lang="en"> 3 <h 阅读全文
posted @ 2023-05-29 10:32 jason2018 阅读(21) 评论(0) 推荐(0) 编辑
摘要: 待用到时再学习 阅读全文
posted @ 2023-05-29 09:59 jason2018 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 待用到时再学习 阅读全文
posted @ 2023-05-29 09:58 jason2018 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 在模板中,通过过滤器实现对变量的处理。 过滤器本质上是 Python 的函数,它会把被过滤器的值当作第1个参数传送给函数。 自定义过滤器 定义 1 def datetime_format(value, format="%Y-%m-%d %H:%M"): 2 return value.strftime 阅读全文
posted @ 2023-05-29 09:56 jason2018 阅读(7) 评论(0) 推荐(0) 编辑
摘要: 渲染模板 index.html 1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>首页</title> 6 </head> 7 <body> 8 <h1>这是首页</h1> 9 </body 阅读全文
posted @ 2023-05-26 14:26 jason2018 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 通过 url_for 函数构造 URL。 url_for 接收视图函数名作为第1个参数,以及其他 URL 定义时的参数,其他参数添加到 URL 的后面作为查询字符串参数。 1 @app.route('/blog/<int:blog_id>') 2 def blog_detail(blog_id): 阅读全文
posted @ 2023-05-26 10:48 jason2018 阅读(6) 评论(0) 推荐(0) 编辑