fix(docs): use configured docs_path in reader
This commit is contained in:
@@ -33,12 +33,22 @@ async def list_docs(req: Request):
|
||||
# Check which exist
|
||||
available = []
|
||||
|
||||
# We use /docs_root/ inside the container (see Dockerfile)
|
||||
# Fallback to "." if running locally without container
|
||||
if os.path.exists("/docs_root"):
|
||||
base_path = "/docs_root"
|
||||
else:
|
||||
base_path = "."
|
||||
from config import get_settings
|
||||
|
||||
# Use configured docs path
|
||||
try:
|
||||
settings = get_settings()
|
||||
base_path = settings.docs_path
|
||||
except:
|
||||
base_path = "docs"
|
||||
|
||||
# Check if absolute or relative
|
||||
if not os.path.isabs(base_path) and not os.path.exists(base_path):
|
||||
# Fallback for docker containers if path not found relative
|
||||
if os.path.exists("/docs_root"):
|
||||
base_path = "/docs_root"
|
||||
else:
|
||||
base_path = "."
|
||||
|
||||
for filename, title in ALLOWED_DOCS.items():
|
||||
if os.path.exists(os.path.join(base_path, filename)):
|
||||
@@ -59,9 +69,18 @@ async def view_doc(req: Request, filename: str):
|
||||
if filename not in ALLOWED_DOCS:
|
||||
raise HTTPException(404, "File not found or not allowed.")
|
||||
|
||||
base_path = "."
|
||||
if os.path.exists("/docs_root"):
|
||||
base_path = "/docs_root"
|
||||
base_path = "docs"
|
||||
try:
|
||||
settings = get_settings()
|
||||
base_path = settings.docs_path
|
||||
except:
|
||||
pass
|
||||
|
||||
if not os.path.isabs(base_path) and not os.path.exists(base_path):
|
||||
if os.path.exists("/docs_root"):
|
||||
base_path = "/docs_root"
|
||||
else:
|
||||
base_path = "."
|
||||
|
||||
file_path = os.path.join(base_path, filename)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user