-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
35 lines (32 loc) · 978 Bytes
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Use Python UMD example</title>
</head>
<body>
<script>
window.process = { env: { NODE_ENV: 'production' } };
</script>
<script src="https://unpkg.com/usepython@0.0.10/dist/py.min.js"></script>
<script>
const py = $py.usePython();
const unbindInstallLog = py.installLog.listen((val) => {
console.log(`Installing Python, stage ${val.stage}: ${val.msg}`)
});
py.log.listen((val) => {
console.log("LOG", val.stdOut)
});
py.load().then(() => {
unbindInstallLog();
console.log("Python is ready");
const script = `print('ok from python')`;
py.run(script).then((res) => {
console.log("Error", res.error);
console.log("Result", res.result);
});
});
</script>
</body>
</html>