@app.before_request
def password_protect():
    if (app.config['PASSWORD_PROTECTED'] and (not request.path.startswith('/static/img'))):
        auth = request.authorization
        if ((not auth) or (auth.password != app.config['PASSWORD'])):
            return make_response('Could not verify your access level for that URL.\nYou have to login with proper credentials', 401, {'WWW-Authenticate': 'Basic realm="Login Required"'})
@app.before_request
def password_protect():
    if (app.config['PASSWORD_PROTECTED'] and (not request.path.startswith('/static/img'))):
        auth = request.authorization
        if ((not auth) or (auth.password != app.config['PASSWORD'])):
            return make_response('Could not verify your access level for that URL.\nYou have to login with proper credentials', 401, {'WWW-Authenticate': 'Basic realm="Login Required"'})