Skip to main content

Create Flask application webhooks with attached handlers

Project description

# Flask-Webhook

Yet another Redis extension for Flask. `Flask-Webhook` makes use of Flask Blueprints and allows easy creation of application webhooks.

[![Latest Version](]
[![Download format](]

## Supported Platforms

* OSX and Linux.
* Python 2.7
* [Flask]( 0.10.1

Probably works with other versions as well.

## Quickstart

pip install Flask-Webhook

from flask import Flask
from flask.ext.webhook import WebHook

app = Flask(__name__)

#create webhook object (name and app are optional)
#if app is not passed in in the constructor, my_webhook.init_app(app) is needed.
my_webhook = WebHook(name='optional_webhook_name', url_prefix='/webhooks' app=app)
my_webhook.add_route('/something', methods=['GET', 'POST'])

#define a function handler to be called by the webhook
def some_function(hookrequest):
do something with the request object received by the webhook

#attach your function handler to the webhook.
#you can attach as many as you want and they all are going to be called
# () should not be included
my_webhook.handlers['some_name_for_your_handler'] = some_function

## Factory Example

from flask.ext.webhook import WebHook

my_webhook = WebHook(url_prefix='/webhooks')

from flask import Flask
from extensions import my_webhook

def some_function(request):
do something

def some_other_function(request):
do something else

def create_app():
app = Flask(__name__)
my_webhook.add_route('/something', methods=['GET', 'POST'])
my_webhook.handlers['action1'] = some_function
my_webhook.handlers['action2'] = some_other_function
return app

from application import create_app

app = create_app()

## Changelog

#### 0.1.0

* Initial release.

Project details

Release history Release notifications

This version


Download files

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

Files for Flask-Webhook, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size Flask-Webhook-0.1.0.tar.gz (3.7 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page