gpt4 book ai didi

python - 如何将 svg 文件加载到我的 python flask 页面中?

转载 作者:行者123 更新时间:2023-12-05 06:33:19 36 4
gpt4 key购买 nike

<分区>

所以我想将一个 svg 文件放入我的页面(不是图像,而是 xml 元素)- 需要它这样我才能动态更改页面中的元素。

然后我编写了一个我认为可以执行的简单代码:

@app.route('/map_test/')
def test():
svg = render_template('file.svg')
response = make_response(svg)
response.content_type = 'image/svg+xml'
return render_template('test.html', svg=response)

和 test.html:

{% block content %}
<section>
{{ svg }}
</section>
{% endblock %}

....刚刚返回 <Response 126181 bytes [200 OK]>而不是 svg 元素...

那么...我需要做什么才能让它发挥作用?

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com