def METHOD_NAME(request):
    if 'q' not in request.GET:
        return HttpResponseForbidden()
    if 'max' in request.GET:
        max_result = int(request.GET["max"])
    else:
        max_result = 3
    result, _ = search_courses(request.GET.get('q', ''), request.user, max_result + 1)
    return HttpResponse(json.dumps({'result': result[:max_result],
                                    'is_limited': True if len(result) > max_result else False}),
                        content_type='application/json')