Skip to content

Instantly share code, notes, and snippets.

@hoangdh
Created August 19, 2021 17:42
Show Gist options
  • Save hoangdh/ad28c52906e1d43e77ccd832eb6daf3f to your computer and use it in GitHub Desktop.
Save hoangdh/ad28c52906e1d43e77ccd832eb6daf3f to your computer and use it in GitHub Desktop.
Webhook example using Python Flask

Webhook Example

#!/usr/bin/python3
# -*- coding: utf-8 -*-

from flask import Flask, request

app = Flask(__name__)

@app.route('/api/webhook', methods=['POST'])
def print_output_webhook():
    data = "Headers: {}\nData: {}\n".format(dict(request.headers) ,request.data)
    return data

app.run()

python3 webhook-example.py

Test with curl:

curl -H "Content-Type: application/text" -X POST -d "I'm Webhook" http://localhost:5000/api/webhook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment