Skip to main content

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

checkconnectnet-1.2.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

checkconnectnet-1.2-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

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

Hashes for checkconnectnet-1.2.tar.gz
Algorithm Hash digest
SHA256 47241dad44c84bc1619e2f37860dec8057ec56145f24ca013d23f176fab021dc
MD5 788c2823071c5989a957461ee24edd27
BLAKE2b-256 6a058df4f153b85ea48b9b308ddf754f650b3b45087cdb60c99589838a03b0a0

See more details on using hashes here.

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

Hashes for checkconnectnet-1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 be6d2274d8b2c423d2e6a829fc017719c751d01fa622aeb39c954cc298300486
MD5 cf65e1b737c10d366a901c1ed210600f
BLAKE2b-256 a95c71a8d661809b05147d980c05329c216dc7da274f78da2dbd2b943d6dce4b

See more details on using hashes here.

Release history Release notifications | RSS feed

1.4

2 files

This release

1.2 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page