Created
November 29, 2024 18:29
-
-
Save gene1wood/908d98a9d6d12933cbba41d80967e0a1 to your computer and use it in GitHub Desktop.
Simple script to launch a Flask listener on all URLs and print out incoming requests with headers and payload
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 __future__ import print_function | |
import sys | |
from flask import Flask, request | |
import json | |
app = Flask(__name__) | |
@app.route('/', defaults={'path': ''}, methods=['GET', 'HEAD', 'POST']) | |
@app.route('/<path:path>', methods=['GET', 'HEAD', 'POST']) | |
def show_payload(path): | |
print('Path : /{}'.format(path)) | |
print(json.dumps({'body': request.json, 'form': request.form, 'headers': {k:v for k, v in request.headers.items()}}, indent=4), file=sys.stderr) | |
return 'Success\n' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment