Skip to content

Instantly share code, notes, and snippets.

@gene1wood
Created November 29, 2024 18:29
Show Gist options
  • Save gene1wood/908d98a9d6d12933cbba41d80967e0a1 to your computer and use it in GitHub Desktop.
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
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