Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- API Checker
- Sends a request to a free Ping endpoint and displays
- the HTTP status code and ping result.
- """
- import json
- import requests
- URL = "https://api.formatdock.com/v1/free/ping"
- def main() -> None:
- try:
- response = requests.get(URL, timeout=10)
- response.raise_for_status()
- data = response.json()
- print(f"Status: {response.status_code}")
- print(f"Result: {data['result']}")
- print("Response:")
- print(json.dumps(data, indent=2, sort_keys=True))
- except requests.RequestException as exc:
- print(f"Request failed: {exc}")
- except (TypeError, ValueError, KeyError) as exc:
- print(f"Unexpected response: {exc}")
- if __name__ == "__main__":
- main()
Advertisement