if request.endpoint and 'static' not in request.endpoint and not login_valid and not getattr(
    app.view_functions[request.endpoint], 'is_public', False):
    return render_template('login.html', next=request.endpoint)
Best way to make Flask-Login's login_required the default