changes 5
Some checks failed
Build Org Website / build (push) Failing after 52s

This commit is contained in:
2026-05-07 16:46:18 +01:00
parent 2df30b9c87
commit 8262a076de
4 changed files with 34 additions and 3 deletions

View File

@@ -397,6 +397,18 @@ def page_to_dict(page: ContentPage) -> dict[str, Any]:
}
def server_diagnostics() -> dict[str, Any]:
pages = list_pages()
return {
"root": ROOT.as_posix(),
"cwd": Path.cwd().as_posix(),
"executable": sys.executable,
"pid": os.getpid(),
"pageCount": len(pages),
"firstPage": pages[0]["path"] if pages else "",
}
def list_pages() -> list[dict[str, Any]]:
pages = []
org_paths = []
@@ -1355,6 +1367,12 @@ class Handler(BaseHTTPRequestHandler):
except Exception as exc:
self.send_json({"error": str(exc)}, HTTPStatus.INTERNAL_SERVER_ERROR)
return
if parsed.path == "/api/diagnostics":
try:
self.send_json(server_diagnostics())
except Exception as exc:
self.send_json({"error": str(exc)}, HTTPStatus.INTERNAL_SERVER_ERROR)
return
if parsed.path == "/api/page":
query = parse_qs(parsed.query)
try:
@@ -1408,8 +1426,12 @@ class Handler(BaseHTTPRequestHandler):
def main() -> None:
port = int(os.environ.get("AUTHOR_PORT", "8765"))
server = ThreadingHTTPServer(("127.0.0.1", port), Handler)
page_count = len(list_pages())
print(f"Authoring UI running at http://127.0.0.1:{port}")
print(f"Content root: {ROOT}")
print(f"Editable pages: {page_count}")
if page_count == 0:
print("WARNING: no editable pages were found. Check AUTHOR_ROOT and the launch directory.")
print("Press Ctrl-C to stop.")
try:
server.serve_forever()