Spaces:
Running
Running
Added test endpoint to check if it's blocked
Browse files- app/server.py +27 -0
app/server.py
CHANGED
|
@@ -227,3 +227,30 @@ async def get_model_info():
|
|
| 227 |
|
| 228 |
except Exception as e:
|
| 229 |
raise HTTPException(status_code=500, detail=str(e))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
|
| 228 |
except Exception as e:
|
| 229 |
raise HTTPException(status_code=500, detail=str(e))
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
import socket
|
| 233 |
+
import subprocess
|
| 234 |
+
|
| 235 |
+
|
| 236 |
+
@app.get("/test-network")
|
| 237 |
+
async def test_network():
|
| 238 |
+
results = {}
|
| 239 |
+
|
| 240 |
+
# Test DNS
|
| 241 |
+
try:
|
| 242 |
+
ip = socket.gethostbyname("www.youtube.com")
|
| 243 |
+
results["dns"] = {"success": True, "ip": ip}
|
| 244 |
+
except Exception as e:
|
| 245 |
+
results["dns"] = {"success": False, "error": str(e)}
|
| 246 |
+
|
| 247 |
+
# Test ping
|
| 248 |
+
try:
|
| 249 |
+
ping = subprocess.run(
|
| 250 |
+
["ping", "-c", "1", "www.youtube.com"], capture_output=True, timeout=5
|
| 251 |
+
)
|
| 252 |
+
results["ping"] = {"success": ping.returncode == 0}
|
| 253 |
+
except Exception as e:
|
| 254 |
+
results["ping"] = {"success": False, "error": str(e)}
|
| 255 |
+
|
| 256 |
+
return results
|