mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-23 04:03:00 -05:00
Add pyscript module in both Main and Workers (#1619)
This commit is contained in:
committed by
GitHub
parent
2774e49ab9
commit
8a01a56e51
28
pyscript.next/test/worker.html
Normal file
28
pyscript.next/test/worker.html
Normal file
@@ -0,0 +1,28 @@
|
||||
<!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" />
|
||||
<script type="module">
|
||||
import { PyWorker } from '../core.js';
|
||||
PyWorker('./worker.py'/*, options allowed except `type` */);
|
||||
// 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>
|
||||
3
pyscript.next/test/worker.py
Normal file
3
pyscript.next/test/worker.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from pyscript import document
|
||||
|
||||
document.body.append("Hello World")
|
||||
Reference in New Issue
Block a user