我是烧瓶的新手,如果问题是基本的,请原谅我,
我正在构建一个应用程序,它要求我有一个表单字段,该字段接受用逗号(“,”)分隔的多个电子邮件ID。
lepl.apps.rfc3696.Email()帮助我们验证电子邮件。
阅读了wtf验证程序的文档后,我在以下代码中
class AlertForm(FlaskForm):
def validate_userEmail(form,field):
email_validator = lepl.apps.rfc3696.Email()
emails = field.data.split(',')
for email in emails:
if not email_validator(email):
raise validators.ValidationError('Please Enter Valid Email Address Seperated By comma')
userEmail = StringField('Email Address',render_kw={'placeholder': 'emaild@domainl.com'}, validators=[validators.DataRequired(),validate_userEmail], id="userEmail")
@app.route('/alerts/', methods=['GET', 'POST'])
def alerts():
form = AlertForm()
return render_template('index.html', form=form)
提交表单后,它将重定向到setAlert端点
@app.route('/setAlert/', methods=['GET', 'POST'])
def alert():
if request.method == "POST":
##write information to db
有人可以为我指出解决当前问题的正确方向。