Files
pyscript/pyscript.core/test/worker.html
2023-08-07 18:36:33 +02:00

35 lines
1.2 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PyScript Next</title>
<link rel="stylesheet" href="../core.css" />
<!-- the worker attribute -->
<script type="module" src="../core.js"></script>
<script type="py" worker="./worker.py" config="./config.json"></script>
<!-- the PyWorker approach -->
<script type="module">
import { PyWorker } from '../core.js';
PyWorker('./worker.py', {config: {fetch: [{files: ['./a.py']}]}});
// the type is overwritten as "pyodide" in PyScript as the module
// lives in that env too
</script>
<script>
// this is only to test non-blocking nature/bootstrap
addEventListener('DOMContentLoaded', () => {
const div = document.body.appendChild(
document.createElement('div')
);
(function monitor() {
const date = new Date;
div.textContent = `${date.getSeconds()}.${date.getMilliseconds()}`;
requestAnimationFrame(monitor);
}());
});
</script>
</head>
</html>