This tool will leverage the requests and click libraries to build a simple CLI program that can be used to check the health of multiple URLs.
-
URL Status Checking
- Check the HTTP status of one or more URLs
- Return appropriate status codes (200 OK, 404, 500, etc.) with reason phrases
- Handle successful responses (2xx status codes) as "OK"
- Handle error responses with actual status code and reason
-
Exception Handling
- Handle timeout errors and return "TIMEOUT" status
- Handle connection errors and return "CONNECTION_ERROR" status
- Handle general request exceptions and return "REQUEST_ERROR: {ExceptionType}" status
- Gracefully handle any unexpected request-related errors
-
Configurable Timeout
- Support configurable timeout for HTTP requests (default: 5 seconds)
- Apply timeout consistently across all URL checks
-
Batch Processing
- Process multiple URLs in a single operation
- Return results as a dictionary mapping URLs to their status
- Handle empty URL lists gracefully
-
Command Line Interface
- Accept multiple URLs as command line arguments
- Provide
--timeoutoption to configure request timeout - Provide
--verbose/-vflag for debug logging - Display usage information when no URLs provided
-
Output Formatting
- Display results in a formatted table-like structure
- Use color coding (green for success, red for errors)
- Show URL and corresponding status for each check
- Comprehensive Logging
- Log start and completion of URL checking operations
- Log individual URL check attempts at debug level
- Log warnings for timeouts and connection errors
- Log errors for unexpected exceptions with full stack traces
- Support configurable log levels (INFO by default, DEBUG with verbose flag)
- Package Distribution
- Installable as a Python package
- Provide console script entry point (
check-urlscommand) - Include proper dependency management (requests, click)
- Support Python 3.9+ compatibility