From d1f170dc77ece50ffc1bddb651beb0bd64a23691 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Fri, 23 Feb 2024 17:36:38 -0800 Subject: [PATCH] fix: error handling --- backend/config.py | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/backend/config.py b/backend/config.py index c9fe0f25c..fadae68ce 100644 --- a/backend/config.py +++ b/backend/config.py @@ -106,23 +106,27 @@ CHANGELOG = changelog_json CUSTOM_NAME = os.environ.get("CUSTOM_NAME", "") if CUSTOM_NAME: - r = requests.get(f"https://api.openwebui.com/api/v1/custom/{CUSTOM_NAME}") - data = r.json() + try: + r = requests.get(f"https://api.openwebui.com/api/v1/custom/{CUSTOM_NAME}") + data = r.json() + if r.ok: + if "logo" in data: + url = ( + f"https://api.openwebui.com{data['logo']}" + if data["logo"][0] == "/" + else data["logo"] + ) - if "logo" in data: - url = ( - f"https://api.openwebui.com{data['logo']}" - if data["logo"][0] == "/" - else data["logo"] - ) + r = requests.get(url, stream=True) + if r.status_code == 200: + with open("./static/favicon.png", "wb") as f: + r.raw.decode_content = True + shutil.copyfileobj(r.raw, f) - r = requests.get(url, stream=True) - if r.status_code == 200: - with open("./static/favicon.png", "wb") as f: - r.raw.decode_content = True - shutil.copyfileobj(r.raw, f) - - WEBUI_NAME = data["name"] + WEBUI_NAME = data["name"] + except Exception as e: + print(e) + pass ####################################