def get_ip(request):
    """
    Attempts to extract the IP number from the HTTP request headers.
    """
    key = "REMOTE_ADDR"
    meta = request.META

    # Lowercase keys
    simple_meta = {k.lower(): v for k, v in request.META.items()}
    ip = meta.get(key, simple_meta.get(key, "0.0.0.0"))
    return ip