[英]I tried to make a python interpreter using skulpt, but ran into an unexpected error. I want to use it on my website
So I am trying to do a python interpreter on my website using skulpt.所以我想在我的网站上使用 skulpt 做一个 python 解释器。 But im running to some issues and dont know how to fix them.但我遇到了一些问题,不知道如何解决它们。 The error will be probably in the js script which is shown below错误可能出现在如下所示的 js 脚本中
Error: Uncaught ReferenceError: Sk is not defined at runit (portfolio:33) at HTMLButtonElement.onclick (portfolio:57)
错误: Uncaught ReferenceError: Sk is not defined at runit (portfolio:33) at HTMLButtonElement.onclick (portfolio:57)
HTML CODE: HTML 代码:
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js" type="text/javascript"></script>
<script src="http://www.skulpt.org/js/skulpt.min.js" type="text/javascript"></script>
<script src="http://www.skulpt.org/js/skulpt-stdlib.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
function outf(text) {
var mypre = document.getElementById("output");
mypre.innerHTML = mypre.innerHTML + text;
}
function builtinRead(x) {
if (Sk.builtinFiles === undefined || Sk.builtinFiles["files"][x] === undefined)
throw "File not found: '" + x + "'";
return Sk.builtinFiles["files"][x];
}
function runit() {
var prog = document.getElementById("yourcode").value;
var mypre = document.getElementById("output");
mypre.innerHTML = '';
Sk.pre = "output";
Sk.configure({output:outf, read:builtinRead});
(Sk.TurtleGraphics || (Sk.TurtleGraphics = {})).target = 'mycanvas';
var myPromise = Sk.misceval.asyncToPromise(function() {
return Sk.importMainWithBody("<stdin>", false, prog, true);
});
myPromise.then(function(mod) {
console.log('success');
},
function(err) {
console.log(err.toString());
});
}
</script>
<h3>Try This</h3>
<form>
<textarea id="yourcode" cols="40" rows="10">import turtle
t = turtle.Turtle()
t.forward(100)
print "Hello World"
</textarea><br />
<button type="button" onclick="runit()">Run</button>
</form>
<pre id="output" ></pre>
<!-- If you want turtle graphics include a canvas -->
<div id="mycanvas"></div>
</body>
</html>
I ran out of ideas how to fix this.我没有办法解决这个问题。 Here is the documentation > https://skulpt.org/using.html这是文档> https://skulpt.org/using.html
Just remove www.
只需删除www.
from script urls.来自脚本网址。
You should use http://skulpt.org/js/skulpt.min.js
instead of http://www.skulpt.org/js/skulpt.min.js
您应该使用http://skulpt.org/js/skulpt.min.js
而不是http://www.skulpt.org/js/skulpt.min.js
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.