How does flask handle POST requests?

I"m reading the flask web development book, and I"m confused about the processing logic of submitting forms to the server through POST.
the following is a code snippet from the book, which is the view function: corresponding to the root path

@app.route("/", methods=["GET", "POST"])
def index():
    name = None
    form = NameForm()
    if form.validate_on_submit():
        name = form.name.data
        form.name.data = ""
    return render_template("index.html", form=form, name=name)

Screenshot of the page:

my idea is: when the user visits the home page for the first time, the browser issues a GET request, and the server calls the index () function to process the request. form is created by NameForm () , so form.validate_on_submit () returns False. However, when a user submits a form through POST, the server should still call the index () function to process the request, so doesn"t that create a new form through form = NameForm () ? Should this new form be empty? Why does form.validate_on_submit () return True? at this time

how does flask handle POST requests involving forms such as the sample code?

Thank you.

Mar.05,2021

-sharp python
-sharp 
-sharp 

-sharp flask-wtf
-sharp Form flask_wtf.form.FlaskForm  wtforms.form

-sharp  flask_wtf.form.FlaskForm  Meta 
-sharp 
def wrap_formdata(self, form, formdata):
  if formdata is _Auto:
    if _is_submitted():
      if request.files:
        return CombinedMultiDict((
          request.files, request.form
        ))
      elif request.form:
        return request.form
      elif request.get_json():
        return ImmutableMultiDict(request.get_json())

    return None

  return formdata

-sharp wtforms.form.BaseFormfiled
def process(self, formdata=None, obj=None, data=None, **kwargs):
  -sharp form
  formdata = self.meta.wrap_formdata(self, formdata)

  if data is not None:
    kwargs = dict(data, **kwargs)

  -sharp formfiled
  for name, field, in iteritems(self._fields):
    if obj is not None and hasattr(obj, name):
      field.process(formdata, getattr(obj, name))
    elif name in kwargs:
      field.process(formdata, kwargs[name])
    else:
      field.process(formdata)
-sharp :
-sharp  __init__ 
-sharp 
-sharp formfiled
-sharp  POST  form.validate_on_submit()  True
form = NameForm()
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf4df5-464c1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf4df5-464c1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?