title: Python Flask user login redirection
body: <p>I have build a very simple user login system without a database, but the redirection is a problem again. If the submitted username &amp; password from the html file is correct then python is doing the following thing:</p>
  
  <pre><code>@app.route("/", methods=['GET', 'POST'])
  def login_page():
      if request.method == 'POST':
          attempted_username = request.form['username']
          attempted_password = request.form['password']
  
          if attempted_username == 'admin' and attempted_password == 'password':
              return redirect(url_for('index'))
          else:
              error='E-Mail or Password not available'
      return render_template('login.html', error=error)
  </code></pre>
  
  <p>Now the URL becomes the following one: <code>shost/index</code> and Chrome tells me then </p>
  
  <pre><code>ERR_NAME_NOT_RESOLVED
  The DNS address of the shost server couldnt be found.
  </code></pre>
  
  <p>Why isn't the URL becoming the <code>server_IP/index</code>, e.g. <code>127.0.0.1/index</code>, because this one works in my browser. How can I prevent flask issue the <code>shost</code> ?</p>
  
  <p>Here is also the html form code for the login:</p>
  
  <pre><code>&lt;form class="text-left" method="post" action=""&gt;
      &lt;input class="mb0" type="text" placeholder="Username" name="username" value="{{request.form.username}}"/&gt;
      &lt;input class="mb0" type="password" placeholder="Password" name="password" value="{{request.form.password}}"/&gt;
      &lt;input type="submit" value="Login"/&gt; 
  &lt;/form&gt;
  </code></pre>
  
  <p>The <code>@app.route("/index")</code> section of the code looks as follows:</p>
  
  <pre><code>@app.route("/index")
  def index():
      return render_template('index.html')
  </code></pre>
  
  <p>Many thanks and best regards</p>