mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-21 03:05:38 -05:00
51 lines
1.7 KiB
HTML
51 lines
1.7 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
|
<title>python workers</title>
|
|
<script type="importmap">
|
|
{
|
|
"imports": {
|
|
"basic-devtools": "../../node_modules/basic-devtools/esm/index.js",
|
|
"coincident/structured": "../../node_modules/coincident/structured.js",
|
|
"@ungap/with-resolvers": "../../node_modules/@ungap/with-resolvers/index.js",
|
|
"@pyscript/core": "../../esm/index.js"
|
|
}
|
|
}
|
|
</script>
|
|
<script type="module">
|
|
import "@pyscript/core";
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<script type="micropython">
|
|
from js import XWorker, Promise, document
|
|
|
|
deferred = Promise.withResolvers()
|
|
|
|
def handle_result(event):
|
|
inputs = document.querySelectorAll('input')
|
|
inputs[0].disabled = True
|
|
inputs[1].disabled = True
|
|
deferred.resolve(inputs[0].value)
|
|
|
|
def handle_input(data):
|
|
inputs = document.querySelectorAll('input')
|
|
inputs[0].placeholder = data
|
|
inputs[0].disabled = False
|
|
inputs[1].disabled = False
|
|
return deferred.promise
|
|
|
|
w = XWorker('./input.lua', type='wasmoon')
|
|
w.sync.input = handle_input
|
|
</script>
|
|
<input type="text" placeholder="loading ..." required disabled />
|
|
<input
|
|
type="submit"
|
|
micropython-click="handle_result(event)"
|
|
disabled
|
|
/>
|
|
</body>
|
|
</html>
|