from flask_wtf import FlaskForm from flask_wtf.file import FileAllowed, FileField, FileRequired from wtforms import StringField, SubmitField from wtforms.validators import DataRequired, Length class TestForm(FlaskForm): description = StringField('Description', validators=[DataRequired(), Length(1, 255)]) file = FileField('File', validators=[FileAllowed(['txt'], 'Plain text only!'), FileRequired()]) submit = SubmitField() title = StringField('Title', validators=[DataRequired(), Length(1, 32)])