feat: python code execution

This commit is contained in:
Timothy J. Baek committed 2024-05-16 17:49:28 -10:00
1 parent ba61f87a2f
commit 58a13aec7e
67 files changed
+1918 -11

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
function execute(id, text) {
// pyscript
let div = document.createElement('div');
let html = `
<py-script type="mpy">
${text}
</py-script>
`;
div.innerHTML = html;
const pyScript = div.firstElementChild;
try {
document.body.appendChild(pyScript);
setTimeout(() => {
document.body.removeChild(pyScript);
}, 0);
} catch (error) {
console.error('Python error:');
console.error(error);
}
}