Skip to content

Instantly share code, notes, and snippets.

@mikejgray
Created February 9, 2020 22:42
Show Gist options
  • Save mikejgray/c3217da53bf937867b22bdce99e6f48f to your computer and use it in GitHub Desktop.
Save mikejgray/c3217da53bf937867b22bdce99e6f48f to your computer and use it in GitHub Desktop.
"""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