Пример #1
0
 def run(self, target_url, expires):
     waspc_celery.send_task(
         name='PeriodicScanner',
         args=[target_url],
         queue='scanner',
         expires=expires
     )
Пример #2
0
    def create(self, request, *args, **kwargs):
        serializer = self.get_serializer(data=request.data)
        serializer.is_valid(raise_exception=True)

        target_url = serializer.validated_data.get('target_url')

        task_id = waspc_celery.send_task(
            name='Scanner',
            args=[target_url],
            queue='scanner'
        ).id
        task_status = waspc_celery.AsyncResult(task_id).status

        headers = self.get_success_headers(serializer.validated_data)

        return Response(
            data={
                'task_id': task_id,
                'task_status': task_status,
                'target_url': target_url
            },
            status=HTTP_201_CREATED,
            headers=headers
        )