我正在构建一个worker,它显示使用python代码triangles.py
生成的svg
文件。在这段python代码中,我有一个函数:
getSVGCode(vw, vh):
⋮
callingOtherFunction(inThisFile)
⋮
return svgCode
需要从Cloudflare Workers上运行的javascript调用此函数(使用下面给出的方法)。svgCode插入到javascript返回到浏览器的html
字符串中
const html = `<!DOCTYPE html>
<body>
<h1>Hello World</h1>
<svg>My svg here</svg>
<p>This markup was generated by a Cloudflare Worker.</p>
</body>`
async function handleRequest(request) {
return new Response(html, {
headers: {
"content-type": "text/html;charset=UTF-8",
},
})
}
addEventListener("fetch", event => {
return event.respondWith(handleRequest(event.request))
})
因此,我想知道一种让Javascript代码将视口维度(vh
和vw
)传递给python函数的方法,以便可以使用此大小生成svg。如果这个选项不可行,我将不得不调整svg的大小,它看起来会被拉伸。我还想知道如何让工作人员也从javascript运行python代码
我是一名代码初学者,尤其是javascript。请提供完整信息,以便我能理解您的答案。谢谢
因此,我想我可以在
html
变量中使用<script></script>
。我用了如下的方法伴随着一具尸体
中提琴.)
相关问题 更多 >
编程相关推荐