Metadata-Version: 2.4
Name: checkconnectnet
Version: 1.2
Summary: A tiny dependency-free Python library for checking internet connectivity.
License-Expression: MIT
Project-URL: Documentation, https://pypi.org/project/checkconnectnet/
Keywords: internet,connectivity,network,online
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Internet
Classifier: Topic :: System :: Networking
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# checkconnectnet

A tiny, dependency-free Python library for checking whether an HTTP or HTTPS endpoint is reachable.

## Installation

```bash
pip install checkconnectnet
```

## Usage

```python
from checkconnectnet import is_connected

if is_connected():
    print("Online")
else:
    print("Offline")
```

You can choose the URL and timeout:

```python
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

```bash
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:

```powershell
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.
