Skip to main content

A REST API for managing background tasks in Django

Project description

Django Task API lets you quickly write background tasks for your Django project and easily call then using the provided REST API, or the included JavaScript library.

What does it look like?

Tasks are defined as classes with typed input and output parameters, and a run function with the task implementation, to be called by a worker processes.

from task_api.tasks import Task
from task_api.params import ListParameter, NumberParameter

class SumNumbers(Task):
    name = 'sum'

    inputs = {
        'numbers': ListParameter(NumberParameter())
    }

    outputs = {
        'sum': NumberParameter()
    }

    def run(self, numbers):
        return sum(numbers)

Tasks are easily called and monitored in front-end code using the included JavaScript API. The API supports both promises (will Polyfill for older browsers) and traditional callbacks.

<script src="{% static 'django-task-api.min.js' %}"></script>

<script type="text/javascript">
    function sumTask(numbers) {
        TaskAPI
            .run('sum', {'numbers': numbers})
            .then(function(json) {
                console.log('Sum: ' + json.outputs.sum)
            })
    }
</script>

Next Steps

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-task-api-1.2.3.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

django_task_api-1.2.3-py2-none-any.whl (14.4 kB view details)

Uploaded Python 2

File details

Details for the file django-task-api-1.2.3.tar.gz.

File metadata

  • Download URL: django-task-api-1.2.3.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5

File hashes

Hashes for django-task-api-1.2.3.tar.gz
Algorithm Hash digest
SHA256 e3ec01b384b32eb16830307b9b0d544c128c4f8d04d684eb84406e65aba0b521
MD5 ac12667d3dd56c5e8727d0389031a416
BLAKE2b-256 6a2fe739e9372a924150f12d227abdf8d94c1862c7c688086a5053c9b1c828a9

See more details on using hashes here.

Provenance

File details

Details for the file django_task_api-1.2.3-py2-none-any.whl.

File metadata

  • Download URL: django_task_api-1.2.3-py2-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5

File hashes

Hashes for django_task_api-1.2.3-py2-none-any.whl
Algorithm Hash digest
SHA256 f47398d674c591b465858c020b2e21450a5faeb1514c75ca04b879f6471a8ae6
MD5 b7b9ce5713570d0284e5400a4b3ac3d4
BLAKE2b-256 846fbc19ee65ff5c064bde97d6daf67750be024372a078baa8c1174fc474e542

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page