Created
July 26, 2022 14:43
-
-
Save Bachmann1234/7d365d3d6d11a7204e89a478794aa210 to your computer and use it in GitHub Desktop.
Webhook dumper
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
from flask import Flask, request | |
import json | |
from pygments import highlight | |
from pygments.formatters.terminal256 import Terminal256Formatter | |
from pygments.lexers import get_lexer_by_name | |
app = Flask(__name__) | |
@app.route("/") | |
def healthcheck(): | |
return "OK" | |
@app.route("/hook", methods=["POST"]) | |
def dump_body(): | |
print(_highlight(json.dumps(dict(request.headers), indent=4))) | |
print(_highlight(json.dumps(request.json, indent=4))) | |
return "OK" | |
def _highlight(json_data): | |
return highlight( | |
code=json_data, | |
lexer=get_lexer_by_name("json"), | |
formatter=Terminal256Formatter(style="solarized-dark"), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment