I created a flask API. Whoever visits that API, I am able to track their IP address. In my situation, i am able to track the local ip from any system which is connected to my internet where I ran the code locally. I deployed the code when I ran the API. It is able to track the public address. I want both public and local IP addresses to be tracked after deployment.
Is there any way to track the local address along with the public address even after deployment using flask and python?
from netifaces import interfaces, ifaddresses, AF_INET
for ifaceName in interfaces():
addresses = [i['addr'] for i in
ifaddresses(ifaceName).setdefault(AF_INET, [{'addr':'No IP addr'}] )]
print '%s: %s' % (ifaceName, ', '.join(addresses))
import socket
hostname = socket.gethostname()
IPAddr = socket.gethostbyname(hostname)
i tried all this but of no use not able to get my desired output
@app.route("/get_my_ip", methods=["GET"])
def get_my_ip():
return jsonify({'ip': request.environ['REMOTE_ADDR']}), 200
Result:10.0.0.1
After the code deployment I am able to get only the public IP. I need to track the local IP along with the public IP.
For example: if 10 different systems connected to one internet used the deployed api, I should get 10 different IP addresses but i am getting the public IP which is common to all. But I expect both public IP and local UP like 106.89.78.90(public IP) 10.0.0.1(private IP) from one system, then 106.89.78.90/10.0.0.2 from another system, and so on.