From e23f66a697f1afab2310a36f73b0d76adc31cf7c Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 7 Jun 2023 15:45:21 +0530 Subject: [PATCH] Fix #1333 - listen_port isn't always present in the config file --- ui/easydiffusion/server.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ui/easydiffusion/server.py b/ui/easydiffusion/server.py index b9ffe5f9..d8940bb5 100644 --- a/ui/easydiffusion/server.py +++ b/ui/easydiffusion/server.py @@ -338,21 +338,22 @@ def get_image_internal(task_id: int, img_id: int): class CloudflareTunnel: def __init__(self): config = app.getConfig() - self.Urls = None - self.port = config["net"]["listen_port"] + self.urls = None + self.port = config.get("net", {}).get("listen_port") def start(self): - self.Urls = try_cloudflare(self.port) + if self.port: + self.urls = try_cloudflare(self.port) def stop(self): - if self.Urls != None: + if self.urls: try_cloudflare.terminate(self.port) - self.Urls = None + self.urls = None @property def address(self): - if self.Urls != None: - return self.Urls.tunnel + if self.urls: + return self.urls.tunnel else: return None