Created
February 9, 2020 22:42
-
-
Save mikejgray/c3217da53bf937867b22bdce99e6f48f to your computer and use it in GitHub Desktop.
This file contains 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
"""Webhook reader.""" | |
import os | |
from flask import Flask, request | |
app = Flask(__name__) | |
@app.route("/events", methods=["POST"]) | |
def webhook(): | |
"""Save the contents of the webhook to a file and return a 204.""" | |
mode = "x" if not os.path.exists("webhooks.txt") else "a" | |
with open("webhooks.txt", mode) as file: | |
file.write(request.data.decode() + "\n") | |
return ("", 204) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment