I'm using Flask-WTF's validate_on_submit() function for very simple one-page website in a such code:
class SignForm(FlaskForm):
testStrField = StringField("enter some text data")
doCheckSign = SubmitField('Check the signed data')
@AppEDS1.route('/', methods=['GET', 'POST'])
def index1():
form = SignForm()
if form.validate_on_submit():
....
In my <form></form>
there are also some buttons with separate JS-handlers for onclick events, and I noticed that each POST-request to my site triggers validate_on_submit() in the way it returns TRUE for each request.
Actually, the only difference between requests is in corresponding Request Payload sections:
(for the "just-onclick-POST-request")
csrf_token=blablabla&testStrField=
(for the "sumbit-POST-request")
csrf_token=blablablabla&testStrField=ggggggggggg&doCheckSign=Check+the+signed+data
So my question is - how actually validate_on_submit() determines whether it was "submit POST request" (have to return TRUE) or just-any-POST-request to website-backend (have to return FALSE but it doesn't)?
question from:
https://stackoverflow.com/questions/65893771/validate-on-submit-from-flask-wtf-always-returns-true 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…