<head>. . . . . . . <script> sagecell.makeSagecell ({ inputLocation: '#plot' }) </ script></ head>. . . . . . .<div id = "plot"> <script type = "text / x-sage" src = "/ src / somegraph.py"> </ script></ div><div id = "plot"> <script type = "application / octet-stream"> bytecode </ script></ div><html>
<head>
<script> sagecell.makeSagecell({ inputLocation: '#pyscript', template: sagecell.templates.minimal, });
</script>
<script src="sagesrc.js"></script></head>
<body onload="sagesrc()">
......
<div id="pyscript"> <script type="text/x-sage" src="somepgm.py"></script>
</div>
.......
</body>
</html>function getPyScr(s) { "use strict"; var xhr; xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { s.innerHTML = this.responseText; } }; xhr.open("GET", s.src, false); //If async is true it does not work xhr.send();}
function sagesrc() { "use strict"; var scrObj, scrObjLen, i; scrObj = document.scripts; scrObjLen = scrObj.length; for (i = 0; i < scrObjLen; i++) { if (scrObj[i].type === "text/x-sage" && scrObj[i].src != "") { getPyScr(scrObj[i]); } }}Hello thereI found a solution:
If the Python script, as in my case, is large it will take some time to loadBut I can write it once and use it several times and in different places