0

I tried the solution here on Python, Flask client ip address. Everything works fine on the HTML side. But if I put this on python code (my app.py file) it shows different IPs.

On my App.py

ip_add = request.environ.get('HTTP_X_REAL_IP', request.remote_addr) #shows ip on amazon. idk what I am doing wrong

On my index.html

{{request.environ.get('HTTP_X_REAL_IP', request.remote_addr)}} #this works fine

Im running it on pythonanywhere by the way. Thanks and good day!

Skrmnghrd
  • 558
  • 4
  • 10
  • are you running **App.py** on your local machine? – Omar Einea Feb 11 '18 at 21:40
  • no sir. Its deployed now (Feb, 11, 2018) at http://skrmnghrd.pythonanywhere.com/ as you can see, it says welcome + your ip. but on the lower part (which is request.environ.get on python side) shows the ip of the amazon – Skrmnghrd Feb 11 '18 at 22:27
  • What's the Amazon IP that it's showing? – Giles Thomas Feb 12 '18 at 15:34
  • 52.91.216.5. this is the amazon Ip that is showing. Im working on a javascript code in the meantime so I can make this functionality – Skrmnghrd Feb 12 '18 at 23:40
  • Hmm. That's the IP address of the proxy server that free PythonAnywhere accounts use to access the Internet. Are you sure you're looking at the same requests in each of the two cases? – Giles Thomas Feb 13 '18 at 16:47
  • Another thing- did you reload your webapp after making those changes? In particular, your template file might be re-rendered on each request but the webapp code wouldn't automatically update and requires a reload on PythonAnywhere. – conrad Feb 15 '18 at 14:43

0 Answers0