code is basically typed according to the flask book whose cover is a dog
.
@users.before_app_request
def before_request():
if current_user.is_authenticated:
current_user.ping()
if not current_user.confirmed \
and request.endpoint[:5] != "user.":
return redirect(url_for("user.unconfirmed"))
the wrong code is also compared several times, just like in the book.
Baidu can"t find any problem either
the following is the error message:
ask for advice
builtins.TypeError
TypeError: "NoneType" object is not subscriptable
Traceback (most recent call last)
This is the Copy/Paste friendly version of the traceback. You can also paste this traceback into a gist:
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 2301, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 2287, in wsgi_app
response = self.handle_exception(e)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1733, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\_compat.py", line 35, in reraise
raise value
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 2284, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1807, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1710, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\_compat.py", line 35, in reraise
raise value
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1803, in full_dispatch_request
rv = self.preprocess_request()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 2079, in preprocess_request
rv = func()
File "D:\exercises\blog\app\views\users.py", line 70, in before_request
and request.endpoint[:5] != "user.":
TypeError: "NoneType" object is not subscriptable