diff --git a/dsLightRag/Start.py b/dsLightRag/Start.py index 20e03a0a..44968400 100644 --- a/dsLightRag/Start.py +++ b/dsLightRag/Start.py @@ -4,6 +4,7 @@ import tempfile import urllib import uuid from io import BytesIO +from urllib import request import fastapi import uvicorn @@ -277,12 +278,11 @@ 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'}) - +@app.post("/api/render_html") +async def render_html(request: fastapi.Request): + data = await request.json() + html_content = data.get('html_content') + # 创建临时文件 filename = f"relation_{uuid.uuid4().hex}.html" filepath = os.path.join('static/temp', filename) @@ -294,10 +294,10 @@ def render_html(): with open(filepath, 'w', encoding='utf-8') as f: f.write(html_content) - return jsonify({ + return { 'success': True, 'url': f'/static/temp/{filename}' - }) + } if __name__ == "__main__":