Answer the question
In order to leave comments, you need to log in
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
from flask import Flask, request
@app.route('/ip/')
def get_user_ip():
ip = request.headers.get('X-Real-IP')
return ip
location / {
...
proxy_set_header X-Real-IP $remote_addr;
...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question