Last active
September 6, 2022 23:55
-
-
Save mhucka/22024d1480de6bea8cbd10e8abf481dc to your computer and use it in GitHub Desktop.
Simple web server that echoes GET and POST content to stdout
This file contains hidden or 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
''' | |
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