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

    Join Date
    Mar 2002
    Posts
    89
    Rep Power
    13

    getting person's ip on my server


    Hello, I am using mod_python+Spyce on my server for my html pages, anyway what I wanna do is show the person's ip address so it can say something like "your ip address is: xxx.xxx.xxx.xxx" someone suggested this code:
    Code:
    import os
    os.environ["REMOTE_ADDR"]
    but it gives me this error:
    Code:
    Spyce exception 
    File: c:/program files/apache group/apache/htdocs/server/main.spy 
    Message: KeyError: REMOTE_ADDR  
    Stack: main.spy:80, in (main):
     print os.environ["REMOTE_ADDR"]
     
    C:\PROGRAM FILES\PYTHON\lib\os.py:387, in __getitem__:
     return self.data[key.upper()]
    basicly what I am looking for is the python equivalent for <?php echo getenv("REMOTE_ADDR"); ?>

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

    Join Date
    Aug 2003
    Posts
    1
    Rep Power
    0

    Lightbulb


    there was a mistake:
    this one works, i am using it in my webpage.

    import os
    os.environ.get('REMOTE_ADDR')

    hope that helps
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    89
    Rep Power
    13
    wow you're a little late lol
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    1
    Rep Power
    0

    Talking


    oops
    haha .. i didnt even check the date..
    i was trying to do the same thing and was looking for answers from google., and i saw your post.. so i replied.. lol

    i guess u have figured it out long time ago eh?
    u should've posted the soln back up

IMN logo majestic logo threadwatch logo seochat tools logo