Unverified Commit f69c0d2e authored by Timothy Jaeryang Baek's avatar Timothy Jaeryang Baek Committed by GitHub
Browse files

Merge pull request #883 from open-webui/custom-name

fix: error handling
parents 1f6b3488 d1f170dc
...@@ -106,23 +106,27 @@ CHANGELOG = changelog_json ...@@ -106,23 +106,27 @@ CHANGELOG = changelog_json
CUSTOM_NAME = os.environ.get("CUSTOM_NAME", "") CUSTOM_NAME = os.environ.get("CUSTOM_NAME", "")
if CUSTOM_NAME: if CUSTOM_NAME:
r = requests.get(f"https://api.openwebui.com/api/v1/custom/{CUSTOM_NAME}") try:
data = r.json() r = requests.get(f"https://api.openwebui.com/api/v1/custom/{CUSTOM_NAME}")
data = r.json()
if "logo" in data: if r.ok:
url = ( if "logo" in data:
f"https://api.openwebui.com{data['logo']}" url = (
if data["logo"][0] == "/" f"https://api.openwebui.com{data['logo']}"
else data["logo"] if data["logo"][0] == "/"
) else data["logo"]
)
r = requests.get(url, stream=True)
if r.status_code == 200: r = requests.get(url, stream=True)
with open("./static/favicon.png", "wb") as f: if r.status_code == 200:
r.raw.decode_content = True with open("./static/favicon.png", "wb") as f:
shutil.copyfileobj(r.raw, 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
#################################### ####################################
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment