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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-task-api-1.2.4.tar.gz
.
File metadata
- Download URL: django-task-api-1.2.4.tar.gz
- Upload date:
- Size: 11.4 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b7efc8547f4e04fedb78edcdcba6fbcd2309eab43dbe26877472f1cb769dfd0 |
|
MD5 | 4f52e4bd944626efcbba37b624898e83 |
|
BLAKE2b-256 | 77cb30bcbfe65d3c133137416a4f72d40f7fb81f7de32ed22f4876d943c60710 |
File details
Details for the file django_task_api-1.2.4-py3-none-any.whl
.
File metadata
- Download URL: django_task_api-1.2.4-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3d6bdb06f2187fb9cf2c46124c008af3967d716f12979a1dd87ba193612180a |
|
MD5 | 15b387215af46959b3d9c3256f77160c |
|
BLAKE2b-256 | a2689e078e60977981cb9ed84ff4386ca25a73944f8816cd2abfa0f807e287ae |