Python flask encountered a 'NoneType' object is not subscriptable error

The

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

< hr >
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
Mar.15,2021

you translate the errors, combined with debug, you can see:

request.endpoint

is probably None, then print (request.endpoint) look at the result, ah, shit! Sure enough, it's None!

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3a503-2c210.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3a503-2c210.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?