Django Listener
Django Listener is a Django app that listens to and process webhooks from different providers.
Installation
Install using pip
pip install django-listener
Usage
Add 'listener' to your INSTALLED_APPS in settings.py.
INSTALLED_APPS = [
...
'listener',
...
]
Run migrations, python manage.py migrate listener
Go to your admin page and add a new Source object.
- Name: Name of the source
- Slug: Slug of the source(automatically generated, but can be changed)
- Url: Url of the source
- Username: Username for basic authentication (if any)
- Password: Password for basic authentication (if any)
- Token: Token for authentication (if any)
- Token Header: Header to be used for token authentication (defaults to
HTTP_AUTHORIZATION) - Active: Whether the source is active or not
- Unique ID Field: The field to be used as the unique identifier for the object (defaults to
id) - HTTP Method: The HTTP method to be used for the webhook (defaults to
POST) - Content Type: The content type to be used for the webhook (defaults to
application/json)
Set up your webhook in the source provider to point to the url https://yourdomain.com/listener/webhooks/<source_slug>/ where <source_slug> is the slug of the source you created.
Example: http://localhost:8080/listener/webhooks/github/
Customization (Optional)
You can customize your webhook processor by changing the LISTENER setting in your settings.py
LISTENER = {
"PROCESSOR": {
"default": "listener.processor.DefaultProcessor",
"github": "path.to.GithubProcessor",
"shopify": "path.to.ShopifyProcessor",
}
},
}
Your processor should be a function that takes in the following parameters:
- event: The event object
Your processor class must have a process method.
For example
class GithubProcessor:
def process(self, event):
# Do something with the event
pass
Contributing
Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.
License
The MIT License (MIT). Please see License File for more information.
Metadata
Release files for django-listener 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-listener-0.1.tar.gz | 8.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_listener-0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.0 kB
Release files / django-listener-0.1.tar.gz
| Download URL | django-listener-0.1.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
603e0a1f22208d88fbd92be880c1f3336d4a444edbf5a2b0e0a219f3c8a909e0
|
|
BLAKE2b-256 checksum How to use checksums |
ae8d3988c436ea9394ef6c891f71d3a1d7ca163dbc88bdf8f003136492a6fdca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.2.0 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.5
|
Release files / django_listener-0.1-py3-none-any.whl
| Download URL | django_listener-0.1-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cbaa34279180f192fc1bf910ae898e585760a06c83db617a550a51b1fa9ca595
|
|
BLAKE2b-256 checksum How to use checksums |
9a60d590ef02cb99a71468d4c003e302bf0de0947b608fb38b9573ef6bb192cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.2.0 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.5
|