pythonflashpyamf

PyAMF: How do you get the client's ip address?


Is there anyway to get the client's ip address when running PyAMF via the WSGI gateway interface (Apache)?


Solution

  • It will be under the key REMOTE_ADDR in your server's request handler. For example, (from the Hello World script):

    httpd = simple_server.WSGIServer(
        ('localhost', 8000),
        simple_server.WSGIRequestHandler,
    )
    
    def app(environ, start_response):
        # environ['REMOTE_ADDR'] is what you're looking for!
        pass
    
    httpd.set_app(app)