Flask can't redirect me to home page, it just gives me the html code as response
<p>I'm building a login with flask and flask-login, and the authentication works perfectly. When a user is authenticated, he should be automatically redirected to the home page (which is unavailable for a not-logged user). The issue is that <code>flask.redirect</code> function just returns me the html code of the home page instead of redirecting to that page. I see the html code in the response object inside the browser console. How can I solve?
Here it is the relevant code:</p>

<pre><code>@app.route('/home')
@flask_login.login_required
def home():
    return render_template('home.html')


@app.route('/login', methods=['GET', 'POST'])
def login():
    if(request.method == 'GET'):
        return render_template('login.html')

    email = request.form['email']
    passwd = request.form['passwd']
    data = getUsersData()
    for key in data:
        if(email == data[key]['email'] and passwd == data[key]['pass']):
            user = User()
            user.id = email
            flask_login.login_user(user, remember=True)
            next = request.args.get('next')
            if(next):
                return redirect(next)
            else:
                return redirect(url_for('home'))

    abort(401) # if inside the for, it can't find valid username and password  
</code></pre>

<p>I would like that when the authentication succeeded, the browser redirects me to <code>localhost:10000/home</code>  </p>

<p>EDIT:
<a href="http://i.stack.imgur.com/FkRXB.png" rel="nofollow">The terminal log with both GET and POST request to <code>/home</code></a></p>

<p>EDIT 2:
<a href="http://i.stack.imgur.com/CwIB3.png" rel="nofollow">The response object</a></p>

<p>If I look at your screen copy, you have something like this:</p>

<pre><code>"POST /login HTTP/1.1" 302 -
"POST /home HTTP/1.1" 200 -
</code></pre>

<p><em>note:</em> you can have exit code 302 or 307, which is approximately the same: a redirection.</p>

<p>So, the redirection from <code>/login</code> to  <code>/home</code> works. No error here.</p>

<p>You said:</p>

<blockquote>
  <p>The issue is that <code>flask.redirect</code> function just returns me the HTML code of the home page instead of redirecting to that page.</p>
</blockquote>

<p>But this is exactly what you implement here:</p>

<pre><code>@app.route('/home')
@flask_login.login_required
def home():
    return render_template('home.html')
</code></pre>

<p>So, I think there is an ambiguity: what do you call "home page"? Is it the page of the <code>/home</code> route, or an "index.html" page which can be the page of the "/" route?</p>

python flask