main
HuangHai 2 weeks ago
parent e035c274bf
commit 63ddd73247

@ -4,6 +4,7 @@ import tempfile
import urllib import urllib
import uuid import uuid
from io import BytesIO from io import BytesIO
from urllib import request
import fastapi import fastapi
import uvicorn import uvicorn
@ -277,12 +278,11 @@ async def update_knowledge(request: fastapi.Request):
return {"code": 1, "msg": str(e)} return {"code": 1, "msg": str(e)}
@app.route('/api/render_html', methods=['POST']) @app.post("/api/render_html")
def render_html(): async def render_html(request: fastapi.Request):
html_content = request.json.get('html_content') data = await request.json()
if not html_content: html_content = data.get('html_content')
return jsonify({'success': False, 'error': 'No HTML content provided'})
# 创建临时文件 # 创建临时文件
filename = f"relation_{uuid.uuid4().hex}.html" filename = f"relation_{uuid.uuid4().hex}.html"
filepath = os.path.join('static/temp', filename) filepath = os.path.join('static/temp', filename)
@ -294,10 +294,10 @@ def render_html():
with open(filepath, 'w', encoding='utf-8') as f: with open(filepath, 'w', encoding='utf-8') as f:
f.write(html_content) f.write(html_content)
return jsonify({ return {
'success': True, 'success': True,
'url': f'/static/temp/{filename}' 'url': f'/static/temp/{filename}'
}) }
if __name__ == "__main__": if __name__ == "__main__":

Loading…
Cancel
Save