forked from Bitmessage/transifex-webhook
Create a simple webhook for flask application
This commit is contained in:
parent
88a061a0ff
commit
79a439d8ed
15
flask_webhook/server.py
Normal file
15
flask_webhook/server.py
Normal 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
10
flask_webhook/webhook.py
Normal 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'})
|
||||
|
Loading…
Reference in New Issue
Block a user