checkconnectnet
A tiny, dependency-free Python library for checking whether an HTTP or HTTPS endpoint is reachable.
Installation
pip install checkconnectnet
Usage
from checkconnectnet import is_connected
if is_connected():
print("Online")
else:
print("Offline")
You can choose the URL and timeout:
from checkconnectnet import check_connection
result = check_connection("https://example.com", timeout=3)
print(result.connected, result.status_code, result.elapsed_seconds, result.error)
The default URL is https://icanhazip.com/. Any HTTP response proves that the network request reached the server, including responses such as 403 or 404.
Command line
checkconnectnet
checkconnectnet --url https://example.com --timeout 3
The command exits with code 0 when connected and 1 when the request fails.
Publishing to PyPI
Create an API token in your PyPI account, then run these commands from this directory:
python -m pip install --upgrade build twine
python -m build
python -m twine check dist/*
$env:TWINE_USERNAME = "__token__"
$env:TWINE_PASSWORD = "pypi-your-api-token"
python -m twine upload dist/*
Do not save the PyPI token in this project or commit it to source control.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file checkconnectnet-1.2.tar.gz.
File metadata
- Download URL: checkconnectnet-1.2.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47241dad44c84bc1619e2f37860dec8057ec56145f24ca013d23f176fab021dc
|
|
| MD5 |
788c2823071c5989a957461ee24edd27
|
|
| BLAKE2b-256 |
6a058df4f153b85ea48b9b308ddf754f650b3b45087cdb60c99589838a03b0a0
|
File details
Details for the file checkconnectnet-1.2-py3-none-any.whl.
File metadata
- Download URL: checkconnectnet-1.2-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be6d2274d8b2c423d2e6a829fc017719c751d01fa622aeb39c954cc298300486
|
|
| MD5 |
cf65e1b737c10d366a901c1ed210600f
|
|
| BLAKE2b-256 |
a95c71a8d661809b05147d980c05329c216dc7da274f78da2dbd2b943d6dce4b
|