Exemple #1
0
def api_autocomplete(request):
    domain = request.GET.get('domain')
    key = request.GET.get('key', '')
    max_results = int(request.GET.get('max', str(DEFAULT_NUM_SUGGESTIONS)))

    return HttpResponse(json.dumps(autocompletion(domain, key, max_results)),
                        'text/json')
Exemple #2
0
def api_autocomplete(request):
    domain = request.GET.get('domain')
    key = request.GET.get('key', '')
    max_results = int(request.GET.get('max', str(DEFAULT_NUM_SUGGESTIONS)))

    if domain is None or key is None or max_results is None:
        return HttpResponse("Please specify 'domain', 'key' and 'max' parameters.", status=400)

    try:
        response = HttpResponse(json.dumps(autocompletion(domain, key, max_results)), 'text/json')
    except Exception:
        logging.error("Exception on getting response from api_autocomplete")
        return HttpResponse(status=500)

    return response
Exemple #3
0
def api_autocomplete(request):
    domain = request.GET.get('domain')
    key = request.GET.get('key', '')
    max_results = int(request.GET.get('max', str(DEFAULT_NUM_SUGGESTIONS)))

    if domain is None or key is None or max_results is None:
        return HttpResponse(
            "Please specify 'domain', 'key' and 'max' parameters.", status=400)

    try:
        response = HttpResponse(
            json.dumps(autocompletion(domain, key, max_results)), 'text/json')
    except Exception:
        logging.error("Exception on getting response from api_autocomplete")
        return HttpResponse(status=500)

    return response
Exemple #4
0
def api_autocomplete(request):
    domain = request.GET.get('domain')
    key = request.GET.get('key', '')
    max_results = int(request.GET.get('max', str(DEFAULT_NUM_SUGGESTIONS)))

    return HttpResponse(json.dumps(autocompletion(domain, key, max_results)), 'text/json')
Exemple #5
0
def api_autocomplete(request):
    domain = request.GET.get("domain")
    key = request.GET.get("key", "")
    max_results = int(request.GET.get("max", str(DEFAULT_NUM_SUGGESTIONS)))

    return HttpResponse(json.dumps(autocompletion(domain, key, max_results)), "text/json")