Spaces:
Sleeping
Sleeping
Update app.py
Browse files- Fix API issues
app.py
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
|
4 |
-
# Fetch the
|
5 |
API_URL = "https://dt074px2e9qbh.cloudfront.net/exploit-api.json"
|
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:
|
@@ -41,7 +41,7 @@ def check_flagged_address(address: str, hf_token: str):
|
|
41 |
# Infer the chain of the address
|
42 |
chain = infer_chain(address, hf_token)
|
43 |
|
44 |
-
# Check if the address is in the
|
45 |
flagged = False
|
46 |
for entry in flagged_addresses:
|
47 |
if isinstance(entry, dict) and "address" in entry:
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
|
4 |
+
# Fetch the flagged addresses once at startup from the data feed (static JSON file)
|
5 |
API_URL = "https://dt074px2e9qbh.cloudfront.net/exploit-api.json"
|
6 |
try:
|
7 |
response = requests.get(API_URL)
|
8 |
+
flagged_addresses = response.json() # Load the JSON data into a list of dictionaries
|
9 |
+
# Ensure the data is a list of dictionaries (addresses)
|
10 |
if not isinstance(flagged_addresses, list):
|
11 |
flagged_addresses = []
|
12 |
except Exception as e:
|
|
|
41 |
# Infer the chain of the address
|
42 |
chain = infer_chain(address, hf_token)
|
43 |
|
44 |
+
# Check if the address is in the flagged addresses
|
45 |
flagged = False
|
46 |
for entry in flagged_addresses:
|
47 |
if isinstance(entry, dict) and "address" in entry:
|