title: How do you clear an entry field in a flask webpage?
body: <p><a href="https://i.stack.imgur.com/Di2NF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Di2NF.png" alt="enter image description here"></a></p>
  
  <p>I am working on my first flask web page.
  When the user types some text and hits "enter" it is added to the file "Save_Inputs.txt".
  The way it works now the user has to delete the text before entering new text.
  I would like the text entry field to automatically clear when "enter" is hit.
  I cannot figure out how the data is persisting and how to clear it.</p>
  
  <p>----- This is the file "view_input.hmtl":</p>
  
  <pre><code>&lt;form method=post action=""&gt;
    Enter text here {{ form.mytext }}
    &lt;input type=submit value=enter&gt;
  &lt;/form
  </code></pre>
  
  <p>----- This is the main routine "flask_app.py":</p>
  
  <pre><code>from flask import Flask, render_template, request
  from wtforms import Form, validators, StringField
  #
  app = Flask(__name__)
  #
  class UploadText(Form):
      mytext = StringField(validators=[validators.InputRequired()])
  #
  @app.route('/', methods=['GET', 'POST'])
  def index():
      form = UploadText(request.form)
      if request.method == 'POST' and form.validate():
          mytext = form.mytext.data
          # add text to the save file
          with open("Save_Inputs.txt", 'a') as out:
              out.write(str(mytext) + '\n')
          return render_template("view_input.html", form=form)
      else:
          return render_template("view_input.html", form=form)
  #
  if __name__ == '__main__':
      app.run(debug=False)
  </code></pre>