Skip to content

Instantly share code, notes, and snippets.

@mhucka
Last active September 6, 2022 23:55
Show Gist options
  • Save mhucka/22024d1480de6bea8cbd10e8abf481dc to your computer and use it in GitHub Desktop.
Save mhucka/22024d1480de6bea8cbd10e8abf481dc to your computer and use it in GitHub Desktop.
Simple web server that echoes GET and POST content to stdout
'''
app.py: Simple web server that echoes GET and POST content to stdout
Usage
-----
1. Save this content into a file named "app.py"
2. Make sure you have Flask installed: "pip3 install flask"
3. Run the following command line: "flask run"
Authors
-------
From an answer posted by user "scnerd" to Stack Overflow on 2017-08-28 at
https://stackoverflow.com/a/45922056/743730
'''
from flask import flask, request
app = flask(__name__)
@app.route('/', methods=['post', 'get'], defaults={'path': ''})
@app.route('/<path:path>', methods=['post', 'get'])
def index(path):
print("http {} to url /{} received json {}".format(request.method, path, request.get_json()))
return "true"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment