Created
June 14, 2017 14:46
-
-
Save seedifferently/8e3d644c000ebc3b3b16b556ef9b0db8 to your computer and use it in GitHub Desktop.
Python ip logger dict example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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