import os # Is server running in a Hugging Face Space? IS_SPACE = os.getenv("SYSTEM") == "spaces" # Database path DATABASE_PATH = os.getenv("DATABASE_DIR", "tmp_data") os.makedirs(DATABASE_PATH, exist_ok=True) DATABASE_FILE = os.path.join(DATABASE_PATH, "database.db") DATABASE_URL = f"sqlite:///{DATABASE_FILE}" # Is frontend served by the server? # In practice: is it running in a production environment? FRONTEND_PATH = os.getenv("FRONTEND_PATH") SERVE_FRONTEND = os.getenv("FRONTEND_PATH") is not None FRONTEND_ASSETS_PATH = os.path.join(FRONTEND_PATH, "assets") if SERVE_FRONTEND else None FRONTEND_INDEX_PATH = ( os.path.join(FRONTEND_PATH, "index.html") if SERVE_FRONTEND else None ) if SERVE_FRONTEND and ( not os.path.exists(FRONTEND_PATH) or not os.path.exists(FRONTEND_ASSETS_PATH) or not os.path.exists(FRONTEND_INDEX_PATH) ): raise FileNotFoundError( f"FRONTEND_PATH {FRONTEND_PATH} has not been built correctly. Please build the frontend first by running `pnpm build` from the 'frontend/' directory." " If you want to run the server in development mode, run `make dev` from the 'backend/' directory and `pnpm dev` from the 'frontend/' directory." )