Flask+Gunicorn+Nginx occur AttributeError "NoneType" has no attribute
<p>I'm reading Flask Web Development book , and now I've deployed my app on VPS.
And I can visit my index page by using IP.
But when I tried to click Login button (The page which you can fill the inforamtion or register the account)
It occurred alarm as below.
I totally dunt get it...why it said the response of flask login is NoneType,
and there is no attribute "set_cookie" "delete_cookie" for it.</p>

<p><a href="https://i.stack.imgur.com/ktvP4.jpg" rel="nofollow"><img src="https://i.stack.imgur.com/ktvP4.jpg" alt="enter image description here"></a></p>

<blockquote>
  <p>Alarm information please check here</p>
</blockquote>

<p><a href="https://i.stack.imgur.com/vP1gV.jpg" rel="nofollow"><img src="https://i.stack.imgur.com/vP1gV.jpg" alt="enter image description here"></a></p>

<blockquote>
  <p>My views.py code for the route "login" as below</p>
</blockquote>

<pre><code>from flask import render_template,redirect,request,url_for,flash
from flask.ext.login import login_user,current_user
from . import auth
from ..models import User
from .forms import LoginForm,RegistrationForm,ChangePasswordForm,PasswordResetRequestForm,PasswordResetForm,ChangeEmailForm
from flask.ext.login import logout_user,login_required
from app import db
from ..email import send_email

@auth.route('/login',methods=['GET','POST'])       
def login():
    form=LoginForm()
    if form.validate_on_submit():
        user=User.query.filter_by(email=form.email.data).first()
        if user is not None and user.verify_password(form.password.data):
            login_user(user,form.remember_me.data)
            return redirect(request.args.get('next')or url_for('main.index'))
        flash('Invalid username or password.')
    return render_template('auth/login.html',form=form)

@auth.before_app_request
def before_request():
    if current_user.is_authenticated:
        current_user.ping()
        if not current_user.confirmed and request.endpoint[:5] !='auth.':
            return redirect(url_for('auth.unconfirmed'))
</code></pre>

<p>Please give some suggestion for me , if need any more information please tell me
Thanks a lot in advance!</p>

<p>Finally I found the problem .
That was caused from another file /main/views.py
At the end of file , there is a function which was used to test the response time , and it return the response object , but I add one extra indentation in the line.
After I cancel one indentation , it works normally.</p>

<pre><code>@main.after_app_request
def after_request(response):
    for query in get_debug_queries():
        if query.duration &gt;= current_app.config['FLAKSY_SLOW_DB_QUERY_TIME']:
            current_app.logger.warning('Slow query: %s\nParameters: %s\nDuration: %fs\nContext: %s\n' %
                (query.statement, query.parameters, query.duration,
                query.context))
    return response
</code></pre>

python html nginx flask