Skip to content

Instantly share code, notes, and snippets.

@ruped24
Last active January 8, 2019 13:27
Show Gist options
  • Save ruped24/3b0e28d4d53e8cd5b4b351640531ebf2 to your computer and use it in GitHub Desktop.
Save ruped24/3b0e28d4d53e8cd5b4b351640531ebf2 to your computer and use it in GitHub Desktop.
#! /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