How to obtain client ip address


#1

Is it possible to find the client ip address in one of the http components?


#2

Use environ['REMOTE_ADDR'] and environ['REMOTE_PORT'], although I don’t recall off the top of my head how those end up working when there are intermediaries between the client and server.


#3

Works perfectly! Thanks…


#4

How can I do this? thanks!


#5
from apistar.server.wsgi import WSGIEnviron

def your_ip(environ: WSGIEnviron):
     return {"ip_addr": envrion["REMOTE_ADDR"]}