如何为我的网站构建可运行的代码片段(适用于 python、c/c++、html/css/js)?

问题描述 投票:0回答:0

2014 年,Stackoverflow 宣布他们支持可运行代码片段:https://stackoverflow.blog/2014/09/16/introducing-runnable-javascript-css-and-html-code-snippets/

例如,我们可以在stackoverflow post中执行如下代码:

<!DOCTYPE html>
<html>
<head>
        <link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
        <script defer src="https://pyscript.net/alpha/pyscript.js"></script>
</head>
<body>
<py-script>
    # Python code here
    import random
    print("Generate random number between 0 and 9 in python:", random.randint(1, 10), sep="\n")
</py-script>
</body>
</html>

我想建立自己的“问答网站”,支持类似的“可运行代码片段”,不仅支持html/css/js,还支持python、c/c++。

我觉得应该用rest api或者wasm。你能告诉我如何实现这个目标吗?

提前致谢。 :)

rest webassembly code-snippets
© www.soinside.com 2019 - 2024. All rights reserved.