Create a simple webhook for flask application

This commit is contained in:
Mohammad Osama Khan 2022-12-22 15:18:07 +05:30
parent 88a061a0ff
commit 79a439d8ed
No known key found for this signature in database
GPG Key ID: 15F978BEFADAB9E1
2 changed files with 25 additions and 0 deletions

15
flask_webhook/server.py Normal file
View File

@ -0,0 +1,15 @@
from flask import Flask, request, abort
app = Flask(__name__)
@app.route('/webhook', methods=['POST'])
def webhook():
if request.method == 'POST':
print(request.json)
return 'success', 200
else:
abort(400)
if __name__ == '__main__':
app.run()

10
flask_webhook/webhook.py Normal file
View File

@ -0,0 +1,10 @@
import requests
import json
webhook_url = 'http://127.0.0.1:5000/webhook'
data = { 'name': 'Request three',
'Channel URL': 'test url3' }
r = requests.post(webhook_url, data=json.dumps(data), headers={'Content-Type': 'application/json'})