fix launching backend without a built frontend

This commit is contained in:
Yeicor
2024-03-03 20:41:44 +01:00
parent 94e316472a
commit 4bd025e7d5

View File

@@ -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,6 +85,7 @@ 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
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={