.gitignore for replit?

import os

def append_banned_ip(ip):
    current_ips = os.getenv("BANNED_IPS", "")
    updated_ips = current_ips + "," + ip if current_ips else ip
    os.environ["BANNED_IPS"] = updated_ips
    return updated_ips

def clear_banned_ips():
    os.environ["BANNED_IPS"] = ""
    return ""

def get_banned_ips():
    return os.getenv("BANNED_IPS", "").split(",")

def is_ip_banned(ip):
    return ip in get_banned_ips()

# Example usage of the functions
# Let's assume you want to add and check banned IPs.

# Add some IPs to the banned list

# Get the list of banned IPs
banned_ips = get_banned_ips()
print("Banned IPs:", banned_ips)

# Check if an IP is banned
ip_to_check = ""
if is_ip_banned(ip_to_check):
    print(f"The IP {ip_to_check} is banned.")
    print(f"The IP {ip_to_check} is not banned.")
# Clear the list of banned IPs
banned_ips = get_banned_ips()
print("Cleared Banned IPs:", banned_ips)

You can use this, try it. This way you can store many IPs using secrets.

When a user forks a repl with this approach, their secrets will be empty and it can store their banned IPs seperately.

Good luck!

PS: If this post helped you, I would really appreciate a Replit follow

1 Like