Skip to content

Instantly share code, notes, and snippets.

@seedifferently
Created June 14, 2017 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seedifferently/8e3d644c000ebc3b3b16b556ef9b0db8 to your computer and use it in GitHub Desktop.
Save seedifferently/8e3d644c000ebc3b3b16b556ef9b0db8 to your computer and use it in GitHub Desktop.
Python ip logger dict example
# assuming "ip_timestamps" is our dict and "req.ip_address" is the requestor's IP address
if req.ip_address in ip_timestamps:
# append the timestamp
ip_timestamps[req.ip_address].append(time.time())
else:
# log the initial timestamp
ip_timestamps[req.ip_address] = [time.time()]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment