How to use the threatexchange.handlers.submit_query function in threatexchange

To help you get started, we’ve selected a few threatexchange examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github crits / crits_services / threatexchange / views.py View on Github external
url = params.get('url', None)
        type_ = params.get('type', None)
        indicator_type = params.get('indicator_type', None)

        if type_:
            del params['type']
        if indicator_type is not None:

            # can probably do better validation here against the attribute
            # of the pytx "Types" enum.
            if indicator_type.strip() != "":
                params['type_'] = params.get('indicator_type')

            del params['indicator_type']

        results = handlers.submit_query(request, url, type_, params=params)
        return HttpResponse(json.dumps(results),
                            content_type="application/json")
    else:
        return render_to_response('error.html',
                                  {'error': "Must be AJAX."},
                                  RequestContext(request))