diff --git a/server.py b/server.py index b178bd6..391c2f4 100644 --- a/server.py +++ b/server.py @@ -6443,6 +6443,87 @@ async def download_client(): ) +# ============================================================================ +# Help / Documentation Routes +# ============================================================================ + +DOCS_DIR = Path(__file__).parent +COMMON_DOCS_DIR = Path(__file__).parent.parent / "common" + +DOCS_MAP = { + "l1": ("L1 Server (Celery)", DOCS_DIR / "README.md"), + "common": ("Common Library", COMMON_DOCS_DIR / "README.md"), +} + + +@app.get("/help", response_class=HTMLResponse) +async def help_index(request: Request): + """Documentation index page.""" + user = await get_optional_user(request) + username = user.username if user else None + + # Build doc links + doc_links = "" + for key, (title, path) in DOCS_MAP.items(): + if path.exists(): + doc_links += f''' + +

{title}

+

View documentation

+
+ ''' + + content = f''' +
+

Documentation

+
+ {doc_links} +
+
+ ''' + return HTMLResponse(render_page("Help", content, username)) + + +@app.get("/help/{doc_name}", response_class=HTMLResponse) +async def help_page(doc_name: str, request: Request): + """Render a README as HTML.""" + if doc_name not in DOCS_MAP: + raise HTTPException(404, f"Documentation '{doc_name}' not found") + + title, doc_path = DOCS_MAP[doc_name] + if not doc_path.exists(): + raise HTTPException(404, f"Documentation file not found") + + user = await get_optional_user(request) + username = user.username if user else None + + # Read and render markdown + import markdown + md_content = doc_path.read_text() + html_content = markdown.markdown(md_content, extensions=['tables', 'fenced_code']) + + content = f''' +
+
+ ← Back to Help +
+
+ {html_content} +
+
+ ''' + return HTMLResponse(render_page(title, content, username)) + + # ============================================================================ # 3-Phase Execution API (Analyze → Plan → Execute) # ============================================================================