Last active
January 12, 2019 03:17
-
-
Save yo-bur/5fcc9e94380c002a36e41b0e04f9cd1b to your computer and use it in GitHub Desktop.
Spawn a HTTP endpoint that returns the IP address of the connecting request.
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
| # Spawn a HTTP endpoint "/ip" that returns the IP address of the connecting | |
| # request. Requires flask. | |
| HOST = "0.0.0.0" | |
| PORT = 7000 | |
| METHODS = ["GET"] | |
| # -- nothing configurable below here -- # | |
| from flask import request | |
| from flask import jsonify, Flask | |
| app = Flask(__name__) | |
| @app.route("/ip", methods=METHODS) | |
| def get_my_ip(): | |
| return jsonify({'ip': request.remote_addr}), 200 | |
| app.run(host=HOST, port=PORT) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment