title: How to get a “nice” URL that can be bookmarked in Flask-WTF?
body: <p>I try to learn Flask and I can't find an answer to the question: Is there a way to get a “clean” URL, that can be bookmarked, if I use GET as form method with the Flask-WTF plugin?</p>
  
  <p>If I use in a template the method POST:</p>
  
  <pre><code>&lt;form method="POST" action=""&gt;
  </code></pre>
  
  <p>The URL in the browser will not alter, in Flask's debug mode it would be:</p>
  
  <pre><code>http://127.0.0.1:5000/
  </code></pre>
  
  <p>If I submit the form.</p>
  
  <p>If I use the method GET, the URL would look like this:</p>
  
  <pre><code>http://127.0.0.1:5000/?name=test&amp;submit=Submit&amp;csrf_token=1453393786%23%23a327427d
  </code></pre>
  
  <p>But I would like to use the Flask-WTF plugin to make forms and get back a nice, bookmarkable URL in the browser like this:</p>
  
  <pre><code>http://127.0.0.1:5000/?name=test
  </code></pre>
  
  <p>Is that possible?</p>
  
  <p>What I try to achieve is something like this in PHP:</p>
  
  <pre><code>&lt;?php
     if( $_GET["name"] ) {
          echo "Hello, ". $_GET['name']. "!";
          exit();
      }
  ?&gt;
  &lt;html&gt;
     &lt;body&gt;
  
        &lt;form action = "&lt;?php $_PHP_SELF ?&gt;" method = "GET"&gt;
           Name: &lt;input type = "text" name = "name" /&gt;
           &lt;input type = "submit" /&gt;
        &lt;/form&gt;
  
     &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>After submitting, I get this URL:</p>
  
  <pre><code>http://127.0.0.1/test.php?name=test
  </code></pre>
  
  <p>I can copy this link, send it to someone else, he or she can open it with a browser and will get the same result. It is simply done, by using the method GET in the form. Look at this: </p>
  
  <pre><code>http://www.utrace.de/?query=8.8.8.8
  </code></pre>
  
  <p>With Flask I cloud do this:</p>
  
  <pre><code>http://127.0.0.1/query/8.8.8.8
  </code></pre>
  
  <p>But what, if I would use more than one parameter? In PHP it would look like this:</p>
  
  <pre><code>http://127.0.0.1/?para1=8.8.8.8&amp;para2=US
  </code></pre>
  
  <p>I've tried it, using this code (lent from Miguel Grinberg):</p>
  
  <p>Program:</p>
  
  <pre><code>from flask import Flask, render_template
  from flask.ext.wtf import Form
  from wtforms import StringField, SubmitField
  from wtforms.validators import Required, Length
  
  app = Flask(__name__)
  app.config['SECRET_KEY'] = 'top secret!'
  
  class NameForm(Form):
      name = StringField('What is your name?', validators=[Required(),
                                                           Length(1, 16)])
      submit = SubmitField('Submit')
  
  @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)
  
  if __name__ == '__main__':
      app.run(debug=True)
  </code></pre>
  
  <p>Template:</p>
  
  <pre><code>&lt;form method="GET" action=""&gt;
      {{ form.name.label }} {{ form.name(size=16) }}
      {% for error in form.name.errors %}
          {{ error }}
      {% endfor %}
       &lt;br&gt;
      {{ form.submit() }}
      {{ form.hidden_tag() }}
  &lt;/form&gt;
      {% if name %}
          &lt;h1&gt;Hello, {{ name }}!&lt;/h1&gt;
      {% endif %}
  </code></pre>