|
|
|
@ -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)
|
|
|
|
|