Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,31 +13,31 @@ def check_proxy(proxy):
|
|
| 13 |
response = requests.get("http://www.google.com", proxies=proxy_dict, timeout=5)
|
| 14 |
response_time = (time.time() - start_time) * 1000 # Convert to ms
|
| 15 |
status = "On"
|
| 16 |
-
except:
|
| 17 |
response_time = 0
|
| 18 |
status = "Off"
|
| 19 |
|
| 20 |
-
# Call ip-api.com for country and ISP
|
| 21 |
try:
|
| 22 |
ip_info = requests.get(f"http://ip-api.com/json/{address}", timeout=5).json()
|
| 23 |
country = ip_info.get("country", "Unknown")
|
| 24 |
isp = ip_info.get("isp", "Unknown")
|
| 25 |
-
except:
|
| 26 |
country = "Unknown"
|
| 27 |
isp = "Unknown"
|
| 28 |
|
| 29 |
return {"address": address, "port": port, "status": status, "response_time": round(response_time, 2), "protocol": "HTTP", "country": country, "isp": isp}
|
| 30 |
|
| 31 |
-
def
|
| 32 |
if not proxy_list:
|
| 33 |
-
|
| 34 |
-
return
|
| 35 |
|
| 36 |
proxies = proxy_list.splitlines()
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
| 41 |
|
| 42 |
def filter_proxies(proxies, status_filter, protocol_filter, country_filter):
|
| 43 |
if not proxies:
|
|
@@ -53,7 +53,7 @@ def filter_proxies(proxies, status_filter, protocol_filter, country_filter):
|
|
| 53 |
|
| 54 |
# Create Gradio interface
|
| 55 |
with gr.Blocks(title="Proxy Checker") as demo:
|
| 56 |
-
gr.Markdown(f"# Proxy Checker - {datetime(2025, 8, 22,
|
| 57 |
|
| 58 |
with gr.Row():
|
| 59 |
with gr.Column():
|
|
@@ -76,7 +76,11 @@ with gr.Blocks(title="Proxy Checker") as demo:
|
|
| 76 |
|
| 77 |
# Logic for checking
|
| 78 |
def update_table(proxy_list):
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
check_button.click(
|
| 82 |
fn=update_table,
|
|
|
|
| 13 |
response = requests.get("http://www.google.com", proxies=proxy_dict, timeout=5)
|
| 14 |
response_time = (time.time() - start_time) * 1000 # Convert to ms
|
| 15 |
status = "On"
|
| 16 |
+
except Exception as e:
|
| 17 |
response_time = 0
|
| 18 |
status = "Off"
|
| 19 |
|
| 20 |
+
# Call ip-api.com for country and ISP with error handling
|
| 21 |
try:
|
| 22 |
ip_info = requests.get(f"http://ip-api.com/json/{address}", timeout=5).json()
|
| 23 |
country = ip_info.get("country", "Unknown")
|
| 24 |
isp = ip_info.get("isp", "Unknown")
|
| 25 |
+
except Exception as e:
|
| 26 |
country = "Unknown"
|
| 27 |
isp = "Unknown"
|
| 28 |
|
| 29 |
return {"address": address, "port": port, "status": status, "response_time": round(response_time, 2), "protocol": "HTTP", "country": country, "isp": isp}
|
| 30 |
|
| 31 |
+
def check_proxies(proxy_list):
|
| 32 |
if not proxy_list:
|
| 33 |
+
return [["No proxies provided", "", "", "", "", "", 0]]
|
|
|
|
| 34 |
|
| 35 |
proxies = proxy_list.splitlines()
|
| 36 |
+
results = []
|
| 37 |
+
with ThreadPoolExecutor(max_workers=5) as executor: # Increased workers for better performance
|
| 38 |
+
results = list(executor.map(check_proxy, proxies))
|
| 39 |
+
|
| 40 |
+
return [[r["address"], r["port"], r["status"], r["protocol"], r["country"], r["isp"], r["response_time"]] for r in results]
|
| 41 |
|
| 42 |
def filter_proxies(proxies, status_filter, protocol_filter, country_filter):
|
| 43 |
if not proxies:
|
|
|
|
| 53 |
|
| 54 |
# Create Gradio interface
|
| 55 |
with gr.Blocks(title="Proxy Checker") as demo:
|
| 56 |
+
gr.Markdown(f"# Proxy Checker - {datetime(2025, 8, 22, 10, 40).strftime('%I:%M %p, %d/%m/%Y +07')}")
|
| 57 |
|
| 58 |
with gr.Row():
|
| 59 |
with gr.Column():
|
|
|
|
| 76 |
|
| 77 |
# Logic for checking
|
| 78 |
def update_table(proxy_list):
|
| 79 |
+
try:
|
| 80 |
+
results = check_proxies(proxy_list)
|
| 81 |
+
return gr.Dataframe.update(value=results)
|
| 82 |
+
except Exception as e:
|
| 83 |
+
return gr.Dataframe.update(value=[["Error", "", "", "", "", "", 0]], visible=True)
|
| 84 |
|
| 85 |
check_button.click(
|
| 86 |
fn=update_table,
|