AnyWebhook (*awh*) is Python/WSGI webhook listener and handler. It simplifies
writing and acting upon incoming webhooks.
Awh splits webhook handling into _validating_ and _executing_. You must register
both validator and executor to handle webhooks. These are simple functions which
accept a request parameter containing incoming request data. Additionaly they
receive a dictionary which is filled with arbitrary data by response manipulator
(a function decorated with `@app.app` decorator). Many validators and executors
(for many different webhooks) can be registered. Any validator returning `True`
marks webhook as correct.
You can also affect application's response by registering a separate function
accepting incoming request and to-be-modified response parameter.
Simple application would look like this:
[[example-app]]
[source,python]
----
import json
import subprocess
from awh import Awh
from awh.operate import require, jsonpath
app = Awh()
@app.validator('foo')
def valid(request, data_dict):
payload = request.get_data(as_text=True)
j = json.loads(payload)
# validate incoming json somehow
require(jsonpath(j, 'password')[0].value == 'secretpass')
require(data_dict.get('foo') == 'bar')
return True
@app.executor('foo')
def execute(request, data_dict):
subprocess.call('deploy-app')
@app.app
def myapp(request, response, data_dict):
response.status_code = 404
data_dict['foo'] == 'bar'
----
For additional examples, see link:tests/apps[tests/apps].
== Deployment
In <<example-app>>, `app` is a WSGI application, which implements its interface
(i.e. a function accepting `environ` and `start_response` parameters). You
should point it to your WSGI server.
Metadata
Release files for awh 0.2.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 | Provenance | Actions |
|---|---|---|---|---|
| awh-0.2.1.tar.gz | 12.9 kB | Without provenance | Details for awh-0.2.1.tar.gz |
Release files / awh-0.2.1.tar.gz
| Download URL | awh-0.2.1.tar.gz |
|---|---|
| Size | 12.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a9edfb8dc1f557f8daf5bc3084008fb66c5883ae8f1b564770b0bf2a7ba93f6a
|
|
BLAKE2b-256 checksum How to use checksums |
43e7ff97713ef8758cca0942ccb68b8966aa50d569b6e73bcd2d5e226ba43128
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for awh 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.