Created
December 15, 2019 05:12
-
-
Save gregelin/88d83e145aaffda196c607a28beb68d1 to your computer and use it in GitHub Desktop.
Example pyodide.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<title>Pyodide</title> | |
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"> | |
<meta content="utf-8" http-equiv="encoding"> | |
<script type="text/javascript" src="pyodide.js"></script> | |
</head> | |
<body> | |
<h1>My Pyodide Page</h2> | |
<h2>This page contains an initial script:</h2> | |
<pre> | |
<script type="text/javascript"> | |
document.getElementById("status").innerHTML = "Pyodide loading..."; | |
languagePluginLoader.then(() => { | |
document.getElementById("status").innerHTML = "Pyodide active"; | |
// pyodide is now ready to use... | |
console.log(pyodide.runPython('import sys\nsys.version')); | |
var pycode = ` | |
import sys | |
sys.version | |
`; | |
rst = pyodide.runPython(pycode) | |
document.getElementById("output").innerHTML = rst; | |
}); | |
</script> | |
<div id="status"></div> | |
<h2>Python output</h2> | |
<div id="output"></div> | |
</pre> | |
<script type="text/javascript"> | |
document.getElementById("status").innerHTML = "Pyodide loading..."; | |
languagePluginLoader.then(() => { | |
document.getElementById("status").innerHTML = "Pyodide active"; | |
// pyodide is now ready to use... | |
console.log(pyodide.runPython('import sys\nsys.version')); | |
var pycode = ` | |
import sys | |
sys.version | |
`; | |
rst = pyodide.runPython(pycode) | |
document.getElementById("output").innerHTML = rst; | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment