我是一个绝对的HTML初学者,我真的不知道我在做什么。我有一个由github托管的网站,我希望它在按下网站上的按钮时在我的计算机上执行python脚本。这是我目前的代码:
<!DOCTYPE html>
<html>
<head>
<h1>Press The Button To Run The Python Script</h1>
</head>
<body>
<input type="button" id='script' name="scriptbutton" value=" Run Script " onclick="goPython()">
<script src="http://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script>
function goPython(){
$.ajax({
url: "MYSCRIPT.py",
context: document.body
}).done(function() {
alert('finished python script');;
});
}
</script>
</body>
</html>
下面是我得到的错误:
Access to XMLHttpRequest at 'file:///C:/Users/Mihkel/Desktop/MYSCRIPT.py' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
myscript.py和test.html文件位于同一目录中。我必须修改python脚本才能使其正常运行吗?对我来说,这个错误似乎是权限错误,是真的吗?