Untitled-1.js 443 Bytes
Newer Older
Timothy J. Baek's avatar
Timothy J. Baek committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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);
	}
}