Horje
python detect internet connection Code Example
python detect internet connection
try:
    import httplib
except:
    import http.client as httplib

def have_internet():
    conn = httplib.HTTPConnection("www.google.com", timeout=5)
    try:
        conn.request("HEAD", "/")
        conn.close()
        return True
    except:
        conn.close()
        return False
# Code by Ivelin on Stack overflow
python check internet connection
import urllib2

def internet_on():
    try:
        urllib2.urlopen('http://216.58.192.142', timeout=1)
        return True
    except urllib2.URLError as err: 
        return False




Python

Related
django create empty migration Code Example django create empty migration Code Example
argparse boolean default Code Example argparse boolean default Code Example
convert list of int to string python Code Example convert list of int to string python Code Example
remove single and double quotes from string python Code Example remove single and double quotes from string python Code Example
how to add images in hml while using flask Code Example how to add images in hml while using flask Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7