mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-20 02:37:41 -05:00
34 lines
767 B
HTML
34 lines
767 B
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<link rel="stylesheet" href="../../../dist/core.css">
|
|
<script type="module" src="../../../dist/core.js"></script>
|
|
</head>
|
|
<body>
|
|
<script type="mpy" worker>
|
|
from pyscript import WebSocket, document
|
|
|
|
def onopen(event):
|
|
print(event.type)
|
|
ws.send("hello")
|
|
|
|
def onmessage(event):
|
|
print(event.type, event.data)
|
|
ws.close()
|
|
|
|
def onclose(event):
|
|
print(event.type)
|
|
document.documentElement.classList.add("ok")
|
|
|
|
ws = WebSocket(
|
|
url="ws://localhost:5037/",
|
|
onopen=onopen,
|
|
onmessage=onmessage,
|
|
onclose=onclose
|
|
)
|
|
</script>
|
|
</body>
|
|
</html>
|