F
F
funnychaak2015-05-03 18:39:48
Flask
funnychaak, 2015-05-03 18:39:48

How to find the ip of the client?

Server: FlASK(python). Hosting: cloud9, how to find out the connection ip?
The request.remote_addr method should return the ip of the connection, and it returns something, but it's not the ip of the client.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
pcdesign, 2015-05-03
@pcdesign

from flask import Flask,   request
@app.route('/ip/')
def get_user_ip():
    ip = request.headers.get('X-Real-IP')
    return ip

V
Vladimir Abiduev, 2015-05-04
@gunlinux

location / {
   ...
   proxy_set_header X-Real-IP $remote_addr;
   ...
}

In nginx if using on your host.
And then request.remote_addr

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question