首页 > 其他分享 >Flask013_宏和 import 语句

Flask013_宏和 import 语句

时间:2023-05-31 09:00:08浏览次数:37  
标签:语句 index textarea Flask013 field html input import

  • 宏  forms.html
1 {% macro input(name, value="",type="text") %}
2 <input type="{{ type }}" value="{{ value | escape }}" name="{{ name }}">
3 {% endmacro %}
4 
5 {% macro textarea(name, value="", rows=10, cols=40) %}
6 <textarea name="{{ name }}" rows="{{ rows }}" cols="{{ cols }}">
7     {{ value | escape }}
8 </textarea>
9 {% endmacro %}
  • 宏使用 index.html
 1 {% from 'forms.html' import input as input_field %}
 2 {% from 'forms.html' import textarea as textarea_field %}
 3 <!DOCTYPE html>
 4 <html lang="en">
 5 
 6 <head>
 7     <meta charset="UTF-8">
 8     <title>宏和 import 语句</title>
 9 </head>
10 
11 <body>
12     <dl>
13         <dt>Username</dt>
14         <dd>{{ input_field('username') }}</dd>
15         <dt>Password</dt>
16         <dd>{{ input_field('password', type="password")}}</dd>
17     </dl>
18     <p>
19         {{textarea_field("comment")}}
20     </p>
21 </body>
22 
23 </html>
  • 模板调用
1 @app.route("/")
2 def index():
3     return render_template("index.html")
  • 效果

 

标签:语句,index,textarea,Flask013,field,html,input,import
From: https://www.cnblogs.com/2018jason/p/17445060.html

相关文章

  • 【python】with as语句
    读文件读写文件是最常见的IO操作。python内置了读写文件的函数,用法和C是兼容的。读写文件前,我们先必须了解一下,在磁盘上读写文件的功能都是由操作系统提供的,现代操作系统不允许普通的程序直接操作磁盘,所以,读写文件就是请求操作系统打开一个文件对象(通常称为文件描述符),然后,通过操......
  • 关于数据库-SQL-between-运算符语句的使用及说明
    关于数据库SQL语句between运算符说明如下1、多用于选取介于两个值之间的数据范围内的值2、运算符选择给定范围内的值。值可以是数字,文本或日期3、是包含性的:包括开始和结束值,且开始值需小于结束值(否则返回空,即0条记录)关于SQL语句between的使用格式如下:selectcolumn_nam......
  • SQLServer 实用语句
    查询过去执行的查询慢SELECTt.text,(qs.total_elapsed_time/1000)/qs.execution_countASavg_elapsed_time,(qs.total_worker_time/1000)/qs.execution_countASavg_cpu_time,((qs.total_elapsed_time/1000)/qs.execution_count)-((qs.total_work......
  • ImportError: /lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found
    [root@localhostPaddleOCR]#strings/lib64/libstdc++.so.6|grep'CXXABI'CXXABI_1.3CXXABI_1.3.1CXXABI_1.3.2CXXABI_1.3.3CXXABI_1.3.4CXXABI_1.3.5CXXABI_1.3.6CXXABI_1.3.7CXXABI_TM_1[root@localhostPaddleOCR]#find/-name"libstdc++.......
  • The Importance of Particle Size Analysis in Preformulation Studies
    Thesizeoftheparticlesiscalledparticlesize.TheparticlesizeoftheAPIiscloselyrelatedtothehomogeneityofthepreparationprocessintermsofmixing,theaccuracyofdosage,andcompressibility,andithasanimpactonthesolubility,durat......
  • SQL语句
    SQL语句分类:DQL:数据查询语言,用于对数据进行查询DML:数据操作语言,对数据进行增加、修改、删除TPL:事务处理语言,对事务进行处理DDL:数据定义语言,进行数据库、表的管理等DCL:数据控制语言,进行授权与权限回收CCL:指针控制语言,通过控制指针完成表的操作数据库的增删改查是必须要掌......
  • Javaweb中在SQL语句中使用未知数进行多表查询
    这个问题主要是匹配好引号和单引号即可。如果是varchar型,那么变量要带单引号('),如果是int型就不用带。同时要注意用+号进行String的拼接。示例:publicList<Student>huizong_bujige(Stringkemu1){List<Student>list=newArrayList<>();Connectionconn......
  • go语言if、for、switch语句
    单分支ifcondition{代码块}if5>2{fmt.Println("5greaterthan2")}Go语言中,花括号一定要跟着if、for、func等行的最后,否则语法出错。condition必须是一个bool类型,在Go中,不能使用其他类型等效为布尔值。if1{}是错误的语句块中可以写其他代码如果con......
  • Flask013_ for 循环语句
    调用[email protected]('/for')2deffor_statement():3books=[{4'title':'三国演义',5'author':'罗贯中',6'price':1007},8{9'ti......
  • Flask013_ if 判断语句
    调用[email protected]('/if')2defif_statement():3age=184returnrender_template('if.html',age=age)if.html1<!DOCTYPEhtml>2<htmllang="en">3<head>4<metacharset="UTF-8......