Created
September 2, 2022 15:13
-
-
Save sandromello/48adfc7e5bf8977a52ad3bd07f443993 to your computer and use it in GitHub Desktop.
Runops Webhooks Receiver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, request | |
from svix.webhooks import Webhook, WebhookVerificationError | |
app = Flask(__name__) | |
# obtained in the svix web panel | |
# https://docs.runops.io/docs/webhooks/#receiving-webhooks | |
signing_secret = '' | |
@app.route("/runops", methods=['POST']) | |
def webhooks(): | |
svix_headers = { | |
'svix-id': request.headers.get('svix-id'), | |
'svix-signature': request.headers.get('svix-signature'), | |
'svix-timestamp': request.headers.get('svix-timestamp') | |
} | |
try: | |
wh = Webhook(signing_secret) | |
task_payload = wh.verify(request.get_data(), svix_headers) | |
print(task_payload) | |
except WebhookVerificationError as e: | |
return {'msg': 'invalid signature'}, 400 | |
return ('', 204) | |
if __name__ == '__main__': | |
app.run(host='0.0.0.0', port=3000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment