xyizko commited on
Commit
10c427b
·
verified ·
1 Parent(s): eb12ccd

Update app.py

Browse files

- Data Strucutre Errors

Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -6,6 +6,9 @@ API_URL = "https://dt074px2e9qbh.cloudfront.net/exploit-api.json"
6
  try:
7
  response = requests.get(API_URL)
8
  flagged_addresses = response.json()
 
 
 
9
  except Exception as e:
10
  flagged_addresses = []
11
  print(f"Failed to load API data: {e}")
@@ -39,7 +42,12 @@ def check_flagged_address(address: str, hf_token: str):
39
  chain = infer_chain(address, hf_token)
40
 
41
  # Check if the address is in the API data
42
- flagged = any(entry.get("address", "").lower() == address.lower() for entry in flagged_addresses)
 
 
 
 
 
43
 
44
  # Format the response
45
  if flagged:
 
6
  try:
7
  response = requests.get(API_URL)
8
  flagged_addresses = response.json()
9
+ # Ensure the data is a list of dictionaries
10
+ if not isinstance(flagged_addresses, list):
11
+ flagged_addresses = []
12
  except Exception as e:
13
  flagged_addresses = []
14
  print(f"Failed to load API data: {e}")
 
42
  chain = infer_chain(address, hf_token)
43
 
44
  # Check if the address is in the API data
45
+ flagged = False
46
+ for entry in flagged_addresses:
47
+ if isinstance(entry, dict) and "address" in entry:
48
+ if entry["address"].lower() == address.lower():
49
+ flagged = True
50
+ break
51
 
52
  # Format the response
53
  if flagged: