Last active
June 11, 2020 21:30
-
-
Save patrick-east/24938c63f373e40c7b5832841605b1b2 to your computer and use it in GitHub Desktop.
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
| FROM python:3 | |
| RUN wget https://gist.githubusercontent.com/patrick-east/24938c63f373e40c7b5832841605b1b2/raw/ca6370c91c255cec91ac9d21a7252f5c6ffdc35d/postr-server.py | |
| RUN mv postr-server.py /bin/postr-server.py | |
| RUN chmod +x /bin/postr-server.py | |
| RUN pip install flask argparse |
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
| #!/usr/bin/env python | |
| import argparse | |
| from flask import abort, Flask, request, send_from_directory | |
| import os | |
| import json | |
| import gzip | |
| app = Flask(__name__) | |
| import logging | |
| log = logging.getLogger('werkzeug') | |
| log.setLevel(logging.ERROR) | |
| @app.route('/<path:path>', methods=['POST']) | |
| def handle_post(path): | |
| print(gzip.decompress(request.data).decode()) | |
| return "{}" | |
| if __name__ == '__main__': | |
| parser = argparse.ArgumentParser(description='Run a server') | |
| parser.add_argument('--port', default=80, help='port to bind on') | |
| args = parser.parse_args() | |
| app.run(host='0.0.0.0', port=args.port) |
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
| flask | |
| argparse |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example to run the container:
Which binds it to port 8222 on the local host (or plumb them together in docker however you would like)