def PushCoT(request): req = json.loads(request.body.decode("utf-8")) ip_address = ATAK_IP if "atak_ip" in req: ip_address = req["atak_ip"] port = ATAK_PORT if "atak_port" in req: port = int(req["atak_port"]) proto = ATAK_PROTO if "atak_proto" in req: proto = int(req["atak_proto"]) cot = CoT.CursorOnTarget() target = cot.atoms(req) if proto == "UDP": cot.pushUDP(ip_address, port, target) if proto == "TCP": cot.pushTCP(ip_address, port, target) json_wrapper = {"cot_xml": urllib.quote(target)} resp = HttpResponse(json.dumps(json_wrapper)) resp.__setitem__("Content-Type", "application/json") return resp
def handle_batch_requests(request, *args, **kwargs): ''' A view function to handle the overall processing of batch requests. ''' batch_start_time = datetime.now() # Generate and fire these WSGI requests, and collect the responses sequential_override = kwargs.pop('run_sequential', False) try: response = execute_requests(request, sequential_override) except BadBatchRequest as brx: # Get results and requests from batch error and populate results = brx.results or [] while len(results) < len(brx.requests): results.append({ 'status_code': 424, 'reason_phrase': "This request was cancelled as it depended on a previous request which did not succeed.", }) response = results # Everything's done, return the response. resp = HttpResponse(content=json.dumps(response), content_type='application/json') if _settings.ADD_DURATION_HEADER: resp.__setitem__( _settings.DURATION_HEADER_NAME, str((datetime.now() - batch_start_time).microseconds / 1000)) return resp
def GetObjectLoB(request): person = ObjectLoB.PersonLoB() lobPerson = person.lob(json.loads(request.body.decode("utf-8"))) resp = HttpResponse(json.dumps(lobPerson)) resp.__setitem__("Content-Type", "application/json") return resp
def WriteToGeopkg(request): req = json.loads(request.body.decode("utf-8")) json_wrapper = { } resp = HttpResponse(json.dumps(json_wrapper)) resp.__setitem__("Content-Type", "application/json") return resp
def LocateTarget(request): t = Triangulator.TargetLoc() logger.info("LocateTarget body=%s",request.body) targetLoc = t.locate(json.loads(request.body.decode("utf-8"))) resp = HttpResponse(json.dumps(targetLoc)) resp.__setitem__("Content-Type", "application/json") return resp
def handle_batch_requests(request, *args, **kwargs): ''' A view function to handle the overall processing of batch requests. ''' batch_start_time = datetime.now() try: # Get the Individual WSGI requests. wsgi_requests = get_wsgi_requests(request) except BadBatchRequest as brx: return HttpResponseBadRequest(content=brx.message) # Fire these WSGI requests, and collect the response for the same. response = execute_requests(wsgi_requests) # Evrything's done, return the response. resp = HttpResponse( content=json.dumps(response), content_type="application/json") if _settings.ADD_DURATION_HEADER: resp.__setitem__(_settings.DURATION_HEADER_NAME, str((datetime.now() - batch_start_time).seconds)) return resp
def handle_batch_requests(request, *args, **kwargs): ''' A view function to handle the overall processing of batch requests. ''' batch_start_time = datetime.now() try: # Get the Individual WSGI requests. wsgi_requests = get_wsgi_requests(request) except BadBatchRequest as brx: return HttpResponseBadRequest(content=str(brx)) # Fire these WSGI requests, and collect the response for the same. response = execute_requests(wsgi_requests) # Evrything's done, return the response. resp = HttpResponse( content=json.dumps(response), content_type="application/json") if _settings.ADD_DURATION_HEADER: resp.__setitem__(_settings.DURATION_HEADER_NAME, str((datetime.now() - batch_start_time).seconds)) return resp
def handle_batch_requests(request, *args, **kwargs): ''' A view function to handle the overall processing of batch requests. ''' batch_start_time = datetime.now() # Generate and fire these WSGI requests, and collect the responses sequential_override = kwargs.pop('run_sequential', False) try: response = execute_requests(request, sequential_override) except BadBatchRequest as brx: return HttpResponseBadRequest(content=str(brx)) # Evrything's done, return the response. resp = HttpResponse(content=json.dumps(response), content_type='application/json') if _settings.ADD_DURATION_HEADER: resp.__setitem__( _settings.DURATION_HEADER_NAME, str((datetime.now() - batch_start_time).microseconds / 1000) ) return resp
def students(request): response = HttpResponse(students_cached(request.GET['discipline_id'], request.GET['group_id']), content_type="json") response.__setitem__("Access-Control-Allow-Origin", "*") add_cross_domain(response) return response