Last active
January 8, 2019 13:27
-
-
Save ruped24/3b0e28d4d53e8cd5b4b351640531ebf2 to your computer and use it in GitHub Desktop.
This file contains 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 | |
from flask import Flask, jsonify, request | |
app = Flask(__name__) | |
@app.route("/.json", methods=["GET"]) | |
def remote_ip(): | |
try: | |
return jsonify({'ip': request.headers['X-Forwarded-For']}), 200 | |
except KeyError: | |
return jsonify({'ip': request.remote_addr}), 200 | |
if __name__ == '__main__': | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment