forked from open-webui/open-webui
fix: error handling
This commit is contained in:
parent
decba05c7a
commit
d1f170dc77
1 changed files with 19 additions and 15 deletions
|
@ -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 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:
|
r = requests.get(url, stream=True)
|
||||||
url = (
|
if r.status_code == 200:
|
||||||
f"https://api.openwebui.com{data['logo']}"
|
with open("./static/favicon.png", "wb") as f:
|
||||||
if data["logo"][0] == "/"
|
r.raw.decode_content = True
|
||||||
else data["logo"]
|
shutil.copyfileobj(r.raw, f)
|
||||||
)
|
|
||||||
|
|
||||||
r = requests.get(url, stream=True)
|
WEBUI_NAME = data["name"]
|
||||||
if r.status_code == 200:
|
except Exception as e:
|
||||||
with open("./static/favicon.png", "wb") as f:
|
print(e)
|
||||||
r.raw.decode_content = True
|
pass
|
||||||
shutil.copyfileobj(r.raw, f)
|
|
||||||
|
|
||||||
WEBUI_NAME = data["name"]
|
|
||||||
|
|
||||||
|
|
||||||
####################################
|
####################################
|
||||||
|
|
Loading…
Reference in a new issue