DEV Community

Discussion on: Django view doesn't output correctly

 
highcenburg profile image
Vicente G. Reyes

Here's what I did

def pingDomain(request, page, url):
    page_object = get_object_or_404(Table, page=page)
    url = page_object.page
    response = requests.head(url)
    try:
        return requests.head(url).ok
    except requests.exceptions.ConnectionError:
        return False
    context = {
        'online': response.ok
    }
    return render(request, 'home.html', context)

Returns nothing :(