首页 > TAG信息列表 > password2
6、WTF表单验证
1、main.py from flask_wtf import FlaskForm from flask import Flask,render_template,request,flash from wtforms import StringField,PasswordField,SubmitField from wtforms.validators import DataRequired,EqualTo app = Flask(__name__) app.secret_key='suib5、使用WTF创建表单
1、main.py from flask_wtf import FlaskForm from flask import Flask,render_template from wtforms import StringField,PasswordField,SubmitField app = Flask(__name__) app.secret_key='suibian' class LoginForm(FlaskForm): username = StringField(3、表单验证
一、python代码 from flask import Flask,render_template,request app = Flask(__name__) @app.route('/',methods=['GET','POST']) def view_template(): if request.method=='POST': username = request.form.get('uFlask_WTF实现表单
Flask_WTF实现表单可分为六个步骤: ①导入FlaskForm扩展包(from flask_wtf import FlaskForm) ②导入StringField,PasswordField,SubmitField (from wtforms import StringField,PasswordField,SubmitField) ③定义表单类 class RegisterForm(FlaskForm): username = StringF前端向后端传递数据
form提交 前端: <!--用table布局、 label的inline-block 对齐input--> <!DOCTYPE html> <html lang="en" xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8" /> <title>Title</title&g