Spaces:
Sleeping
Sleeping
Download test_api.py from SurLink/Anti-Phishing-Scanner-0: direct link, hf CLI and curl.
- Browser
- Download file 903 Bytes
-
https://huggingface.co/spaces/SurLink/Anti-Phishing-Scanner-0/resolve/main/test_api.py
- Command line
-
hf download hf://spaces/SurLink/Anti-Phishing-Scanner-0/test_api.py
-
curl -L -o test_api.py https://huggingface.co/spaces/SurLink/Anti-Phishing-Scanner-0/resolve/main/test_api.py
903 Bytes
| import os | |
| import requests | |
| import sys | |
| import json | |
| API_BASE = os.getenv("API_BASE", "http://localhost:8080") | |
| MESSAGE = os.getenv("TEST_MESSAGE", "Please verify your account at http://example.com/login") | |
| TIMEOUT = int(os.getenv("TEST_TIMEOUT", "10")) | |
| endpoints = ["/analyze", "/analyze/or1", "/analyze/or2"] | |
| print(f"Testing API at {API_BASE} with message: {MESSAGE}\n") | |
| for ep in endpoints: | |
| url = API_BASE.rstrip("/") + ep | |
| payload = {"message": MESSAGE} | |
| try: | |
| resp = requests.post(url, json=payload, timeout=TIMEOUT) | |
| try: | |
| body = resp.json() | |
| except Exception: | |
| body = resp.text | |
| print(f"Endpoint: {ep} -> Status: {resp.status_code}") | |
| print(json.dumps(body, indent=2, ensure_ascii=False)) | |
| except requests.exceptions.RequestException as e: | |
| print(f"Endpoint: {ep} -> Request failed: {e}") | |
| print("---") | |
| print("Done.") | |