#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    4
    Rep Power
    0

    New to Python: Get client IP address in Spyce


    So, I have a Spyce page that I want to use to get the client's IP address. I know this is something simple but I just can't get it working.

    I tried the following code:

    Code:
    =cgi.os.getenv('REMOTE_ADDR')
    But all I get back is "None".

    Many thanks,
    Joel
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    You're looking for is the env() function in spyces request module.

    env( [name], [default] ):
    Returns a dictionary with CGI-like environment information of this request. If name is specified then a single entry is returned if the parameter exists, otherwise default, which defaults to None, if omitted.
    http://spyce.sourceforge.net/doc-mod_request.html

    Mark.
    programming language development: www.netytan.com Hula

  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    4
    Rep Power
    0

    Thanks


    Hey Netytan,

    Thanks a million for straightening me out. I should have posted this much earlier and saved myself many frustrations. I've lurked here long enough to know that you are the man and I wasn't let down

    I'm digging this python thing but I'm still trying to get my arms around the different modules in spyce vs python. For some reason, I have a much harder time navigating the documentation than I do in PHP or Java (okay, that's probably 'cuz I'm much more familiar with them ).

    Thanks again,
    Joel
  6. #4
  7. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    No problem at all Galberras anything else i can help you with dont hesitate to ask . Thanks for the kind words

    I know what your talking about Pythons docs are so big that its not always easy to get to where you want, the trick with Spyce is to stick to its modules where possible.

    Mark.
    programming language development: www.netytan.com Hula


IMN logo majestic logo threadwatch logo seochat tools logo