跳转到主要内容

Python + Webhooks 简化制作

项目描述

https://pypip.in/d/webhooks/badge.png https://badge.fury.io/py/webhooks.png Build Status Wheel Status

Python + Webhooks 简化制作

警告:该项目处于预alpha状态。它不适合用于任何东西。

Python版本

目前适用于

  • Python 2.7

  • Python 3.3

现有功能

  • 易于集成到任何包或项目中

  • 包含同步webhooks的几个内置发送器。

  • 包含RedisQ驱动的异步webhook。

  • 通过使用自定义发送器和哈希函数扩展功能。

计划中的功能

  • 包含同步和异步webhooks的许多内置发送器。

  • 针对将多个具有相同负载发送到同一目标的多个发送进行合并的特殊功能。

  • 遵循 http://resthooks.org 模式

  • 优秀的文档

  • PyPy兼容性

用法

按照以下简单步骤操作

  1. 导入 webhook 装饰器。

  2. 定义一个返回可序列化为JSON的字典或可迭代的函数。

  3. 添加 webhook 装饰器并传入一个 sender_callable

  4. 调用函数!

同步示例(异步示例即将推出)

>>> from webhooks import webhook
>>> from webhooks.senders import targeted

>>> @webhook(sender_callable=targeted.sender)
>>> def basic(url, wife, husband):
>>>     return {"husband": husband, "wife": wife}

>>> r = basic(url="http://httpbin.org/post", husband="Danny", wife="Audrey")
>>> import pprint
>>> pprint.pprint(r)
{'attempt': 1,
'hash': '29788eb987104b8a87d201292fa459d9',
'husband': 'Danny',
'response': b'{\n  "args": {},\n  "data": "",\n  "files": {},\n  "form": {\n    "attempt": "1",\n    "hash": "29788eb987104b8a87d201292fa459d9",\n    "husband": "Danny",\n    "url": "http://httpbin.org/post",\n    "wife": "Audrey"\n  },\n  "headers": {\n    "Accept": "*/*",\n    "Accept-Encoding": "gzip, deflate",\n    "Connection": "close",\n    "Content-Length": "109",\n    "Content-Type": "application/x-www-form-urlencoded",\n    "Host": "httpbin.org",\n    "User-Agent": "python-requests/2.3.0 CPython/3.3.5 Darwin/12.3.0",\n    "X-Request-Id": "d25119e4-08ba-4523-abc4-b9a9ac10225b"\n  },\n  "json": null,\n  "origin": "108.185.146.101",\n  "url": "http://httpbin.org/post"\n}',
'status_code': 200,
'url': 'http://httpbin.org/post',
'wife': 'Audrey'}

由Webhooks驱动的项目

历史

0.4.2 (2014-05-22)

  • 当使用Python 3时,将python-requests字节转换为字符串

0.4.1 (2014-05-22)

  • json262 替换为 standardjson 包。

0.4.0 (2014-05-20)

  • utils.encoders 替换为 json262 包。

  • 在所有地方使用utf-8编码

  • 在所有地方添加 from `__future__ import absolute_import

0.3.2 (2014-05-17)

  • 引入了简化的 cached_property 装饰器

0.3.1 (2014-05-15)

  • 添加了更多可发送属性,以便更容易跟踪正在发生的事情。

  • 在setup.py中添加了缺失的webhooks.sender包。

0.3.0 (2014-05-14)

  • 添加了可扩展的Senderable类,以加快创建新发送者的过程。

  • 添加了async_redis发送者。

  • 添加了travis-ci。

0.2.0 (2014-05-13)

  • 添加了功能性的钩子装饰器。

  • 提高了测试覆盖率。

  • 哈希函数被放置在自己的模块中。

  • 感谢Audrey Roy Greenfeld,清理了JSON编码器!

0.1.0 (2014-05-07)

  • 首次发布于PyPI。

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪一个,请了解更多关于安装包的信息。

源分布

webhooks-0.4.2.tar.gz (17.0 kB 查看哈希值)

上传日期

构建分布

webhooks-0.4.2-py2.py3-none-any.whl (10.7 kB 查看哈希值)

上传日期 Python 2 Python 3

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面