我正在尝试创建一个以我在 python 上开发的算法为中心的网站。我的愿景是用户会输入一些东西,然后接收使用 python 生成的输出。我也在尝试调用 python 文件,因为我需要实现的 python 代码量很大。
为简单起见,我将如何将此 python 文件实现到带有输入空格的网站中:
数学.py
def calc(a, b):
c = a + b
return c
我试图理解 brython 并使用了他们提供的示例,但是它不起作用:
索引.html
<html>
<script src="https://raw.githack.com/brython-dev/brython/master/www/src/brython.js"></script>
<script src="https://raw.githack.com/brython-dev/brython/master/www/src/brython_stdlib.js"></script>
<body onload="brython()">
<input type="text" id="text" placeholder="Enter anything in mind">
<span id="output"></span>
<script src="C:\ExampleCode\example.py"
type="text/python" id="script1"></script>
</body>
</html