diff --git a/dsLightRag/Start.py b/dsLightRag/Start.py index ddda4325..ad59418c 100644 --- a/dsLightRag/Start.py +++ b/dsLightRag/Start.py @@ -273,5 +273,28 @@ async def update_knowledge(request: fastapi.Request): return {"code": 1, "msg": str(e)} +@app.route('/api/render_html', methods=['POST']) +def render_html(): + html_content = request.json.get('html_content') + if not html_content: + return jsonify({'success': False, 'error': 'No HTML content provided'}) + + # 创建临时文件 + filename = f"relation_{uuid.uuid4().hex}.html" + filepath = os.path.join('static/temp', filename) + + # 确保temp目录存在 + os.makedirs('static/temp', exist_ok=True) + + # 写入文件 + with open(filepath, 'w', encoding='utf-8') as f: + f.write(html_content) + + return jsonify({ + 'success': True, + 'url': f'/static/temp/{filename}' + }) + + if __name__ == "__main__": uvicorn.run(app, host="0.0.0.0", port=8000) diff --git a/dsLightRag/static/ShiJi.html b/dsLightRag/static/ShiJi.html index fe200d26..dbc67441 100644 --- a/dsLightRag/static/ShiJi.html +++ b/dsLightRag/static/ShiJi.html @@ -350,7 +350,7 @@ function generateRelation() { const answerArea = document.getElementById('answerArea'); answerArea.innerHTML = '