0

In my python project I have to track user IP address and country and region, and other information, I used "https://ipapi.co/json/" for tracking the IP address, but thing is when i deploy my model(web-app) on the deployment website, it is giving me that server IP address instead who is using my web-app. when i try in my local machine it is giving my IP address. Actually, i am currently new and don't know that much about tracking IP another. Please anyone can describe how i will achieve this thing. how to track the user of my web-app IP address instead of the deployment server IP address.

Ref- I am using streamlit sharing for the deployment it is giving me streamlit office address instead of my friend(test user) IP. I need my fried IP address when he is using the deployed web app. Thank you sir for your consideration, a help will be great for me, am really stuck here. my project in Python.

SUBHABRATA NATH
  • 125
  • 1
  • 6
  • How are you using `https://ipapi.co/json` that it doesn't work for you? Are you requesting it from client-side code or server-side code? Are you using a specific Python framework for your web application? Have you looked up how to get the client's IP in that framework or in Python in general? It's not really clear what you've tried or how it isn't working. – David Jul 30 '21 at 14:04
  • #David sorry sir, i did not write it clearly. am new on these things like tracking IP and others. never done before, I am using streamlit for creating the web app. and when my friend is using the web app(from India) it is giving me the United States. same with me after deployed on "streamlit sharing" - it is giving this behavior. My requirement is to get my friend's IP address. i just want to know how to solve this. Any tutorial or any article will be great sir, so i can read through. – SUBHABRATA NATH Jul 30 '21 at 14:15

1 Answers1

0

It sounds like you're trying to get the IP from this 3rd party service from your server, which would of course return the server's IP address.

Based on a comment on the question:

I am using streamlit for creating the web app.

Based on a cursory Google search, it sounds like getting the client's IP is non-trivial in that system:

(Based on this I would probably recommend using a different Framework/platform for building web applications. This sounds... extremely limited. But that's another matter entirely.)

The service you reference would need to be accessed from the client computer, which means accessing it from JavaScript. If that service doesn't allow CORS requests, there are other options available. Once you have the value(s) you need in JavaScript, you can send them to your server-side code via an AJAX request, a Form POST, etc.

David
  • 208,112
  • 36
  • 198
  • 279
  • Thank you so much for your time and effort, I will try with another framework like by this time am only know flask, And thank you again for your help. – SUBHABRATA NATH Jul 30 '21 at 14:34