Markdown渲染 + PRD需求文档(H Tab)
- mdRender(): 支持h1-h6/table/list/code/bold/link/blockquote/hr - G 规范: dev-spec.md 以渲染后HTML展示 - H 需求: PRD.md 以渲染后HTML展示 - /api/prd: 新增路由读取PRD.md
This commit is contained in:
@@ -941,6 +941,29 @@ def api_spec():
|
||||
return jsonify({"ok": False, "error": str(e), "content": ""})
|
||||
|
||||
|
||||
@app.route("/api/prd")
|
||||
def api_prd():
|
||||
"""返回产品需求文档 (PRD) 内容"""
|
||||
candidates = [
|
||||
os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "docs", "PRD.md"),
|
||||
os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "docs", "PRD.md"),
|
||||
]
|
||||
prd_path = None
|
||||
for c in candidates:
|
||||
p = os.path.normpath(c)
|
||||
if os.path.exists(p):
|
||||
prd_path = p
|
||||
break
|
||||
if not prd_path:
|
||||
return jsonify({"ok": False, "error": "PRD.md not found", "content": ""})
|
||||
try:
|
||||
with open(prd_path, "r", encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
return jsonify({"ok": True, "content": content, "path": prd_path})
|
||||
except Exception as e:
|
||||
return jsonify({"ok": False, "error": str(e), "content": ""})
|
||||
|
||||
|
||||
@app.route("/api/platform")
|
||||
@app.route("/api/health")
|
||||
def api_health():
|
||||
|
||||
Reference in New Issue
Block a user