From 620caf9caa7e642028779db5548a6b358183efec Mon Sep 17 00:00:00 2001 From: ArabCoders Date: Fri, 16 Feb 2024 16:07:20 +0300 Subject: [PATCH] Attempt at fix for response hang when the app has been running for long time. --- app/main.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/main.py b/app/main.py index 095eccb4..6e65f265 100644 --- a/app/main.py +++ b/app/main.py @@ -31,6 +31,7 @@ class Main: connection: sqlite3.Connection = None queue: DownloadQueue = None loop: asyncio.AbstractEventLoop = None + appLoader: str = None def __init__(self): self.config = Config.get_instance() @@ -349,10 +350,14 @@ class Main: @self.routes.get(self.config.url_prefix) async def index(_) -> Response: - return web.FileResponse(os.path.join( - os.path.dirname(os.path.dirname(os.path.realpath(__file__))), - 'frontend/dist/index.html' - )) + if not self.appLoader: + with open(os.path.join( + os.path.dirname(os.path.dirname(os.path.realpath(__file__))), + 'frontend/dist/index.html' + ), 'r') as f: + self.appLoader = f.read() + + return web.Response(text=self.appLoader, content_type='text/html', charset='utf-8', status=200) @self.sio.event() async def connect(sid, environ):