From 4bd025e7d5a83b985cf6a26642817abf66bf20c5 Mon Sep 17 00:00:00 2001 From: Yeicor <4929005+Yeicor@users.noreply.github.com> Date: Sun, 3 Mar 2024 20:41:44 +0100 Subject: [PATCH] fix launching backend without a built frontend --- yacv_server/server.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/yacv_server/server.py b/yacv_server/server.py index 36c97fe..870a774 100644 --- a/yacv_server/server.py +++ b/yacv_server/server.py @@ -28,6 +28,7 @@ if not os.path.exists(FRONTEND_BASE_PATH): FRONTEND_BASE_PATH = os.path.join(FILE_DIR, '..', 'dist') else: logger.warning('Frontend not found at %s', FRONTEND_BASE_PATH) + FRONTEND_BASE_PATH = None # Define the API paths (also available at the root path for simplicity) UPDATES_API_PATH = '/api/updates' @@ -84,7 +85,8 @@ class Server: self.app.router.add_get('/', self._entrypoint) # - Static files from the frontend self.app.router.add_get('/{path:(.*/|)}', _index_handler) # Any folder -> index.html - self.app.router.add_static('/', path=FRONTEND_BASE_PATH, name='static_frontend') + if FRONTEND_BASE_PATH is not None: + self.app.router.add_static('/', path=FRONTEND_BASE_PATH, name='static_frontend') # --- CORS --- cors = aiohttp_cors.setup(self.app, defaults={ "*": aiohttp_cors.ResourceOptions(