mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-23 05:26:37 +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 sys
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
TIMEOUT = 5 # Seconds
|
TIMEOUT = 5 # Seconds
|
||||||
|
HTTP_USER = os.getenv('HTTP_USER')
|
||||||
|
HTTP_PASS = os.getenv('HTTP_PASS')
|
||||||
|
|
||||||
|
|
||||||
def do_heatlhcheck(url):
|
def do_heatlhcheck(url):
|
||||||
headers = {'User-Agent': 'healthcheck'}
|
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
|
return response.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user