mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-22 21:16:38 +00:00
add http auth support to healthcheck, related to #472
This commit is contained in:
parent
246e2a3187
commit
e28c698f7e
@ -10,16 +10,22 @@
|
||||
'''
|
||||
|
||||
|
||||
import os
|
||||
import sys
|
||||
import requests
|
||||
|
||||
|
||||
TIMEOUT = 5 # Seconds
|
||||
HTTP_USER = os.getenv('HTTP_USER')
|
||||
HTTP_PASS = os.getenv('HTTP_PASS')
|
||||
|
||||
|
||||
def do_heatlhcheck(url):
|
||||
headers = {'User-Agent': 'healthcheck'}
|
||||
response = requests.get(url, headers=headers, timeout=TIMEOUT)
|
||||
auth = None
|
||||
if HTTP_USER and HTTP_PASS:
|
||||
auth = (HTTP_USER, HTTP_PASS)
|
||||
response = requests.get(url, headers=headers, auth=auth, timeout=TIMEOUT)
|
||||
return response.status_code == 200
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user