-
-
Save ruanbekker/b745d6cb3bf56d4105f08b19eac6d8fc to your computer and use it in GitHub Desktop.
from flask import Flask, request, jsonify | |
app = Flask(__name__) | |
@app.route('/ip', methods=['GET']) | |
def name(): | |
return request.environ.get('HTTP_X_REAL_IP', request.remote_addr) | |
#return jsonify({'ip': request.remote_addr}), 200 | |
#return jsonify({'ip': request.environ['REMOTE_ADDR']}), 200 | |
if __name__ == '__main__': | |
app.run(host='0.0.0.0', port=80) |
this is return the localhost ip, how to get the public ip with flask?
this is return the localhost ip, how to get the public ip with flask?
Perhaps you were running this in development....if you put it on a server (like gunicorn) ... it should return the ip of the client
this is return the localhost ip, how to get the public ip with flask?
Perhaps you were running this in development....if you put it on a server (like gunicorn) ... it should return the ip of the client
and how i can change it?
this is return the localhost ip, how to get the public ip with flask?
Perhaps you were running this in development....if you put it on a server (like gunicorn) ... it should return the ip of the client
and how i can change it?
Clearly the IP
is the one sent with the HTTP request
, there are no other IP
s as far as Flask is concerned.
https://werkzeug.palletsprojects.com/en/0.15.x/wrappers/#werkzeug.wrappers.BaseRequest.remote_addr
Thank you, it helped a lot.