-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic.html
More file actions
70 lines (67 loc) · 3.04 KB
/
Copy pathbasic.html
File metadata and controls
70 lines (67 loc) · 3.04 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Basics - pyproc</title>
<link rel="icon" href="../assets/logo.svg">
<meta name="theme-color" content="#0a0f1c">
<link rel="stylesheet" href="demo.css">
<script type="module" src="siteChrome.js"></script>
</head>
<body>
<div class="wrap">
<header class="site">
<a class="logo" href="../"><img class="logoMark" src="../assets/logo.svg" width="22" height="22" alt=""> <span><span class="py">py</span>proc</span></a>
<nav>
<a href="agentSandbox.html">Agent</a>
<a href="machine.html">Machine</a>
<a href="serverDev.html">Server</a>
<a href="speedLab.html">Speed</a>
<a href="terminal.html">Terminal</a>
<a href="processOs.html">Process OS</a>
<a href="basic.html" class="on">Basics</a>
</nav>
<sns-links></sns-links>
</header>
<h1>Boot and run</h1>
<p class="lead">Real CPython 3.14 booting in this tab via WebAssembly, then running code and loading numpy. No server involved.</p>
<div class="panel">
<div class="status" id="st">Booting CPython...</div>
<div class="term" id="out"></div>
</div>
<footer class="site">Chromium/Edge. Source: <a href="https://github.com/eddmpython/pyproc">github.com/eddmpython/pyproc</a> · <a href="https://www.npmjs.com/package/pyproc">npm install pyproc</a></footer>
</div>
<script type="module">
import { boot } from "../index.js";
const out = document.getElementById("out"), st = document.getElementById("st");
const log = (m) => { out.textContent += m + "\n"; };
// 예제 실행 게이트(?gate): 완주 여부를 하네스에 보고. 사람이 열면 no-op.
const params = new URLSearchParams(location.search);
const gateMode = params.has("gate");
const INDEX = params.get("indexURL") ? new URL(params.get("indexURL"), location.href).href : undefined;
const gateReport = (ok) => { if (!gateMode) return; fetch("/gateReport", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ ok: !!ok, checks: [{ name: document.title, pass: !!ok, info: out.textContent.slice(-180) }] }) }).catch(() => {}); };
try {
let t = performance.now();
const machine = await boot({ indexURL: INDEX });
st.textContent = `Ready in ${Math.round(performance.now() - t)}ms`;
log(">>> sum(range(100))");
const s = machine.run("sum(range(100))");
log(String(s));
log("");
log("# pip-grade packages work too:");
t = performance.now();
await machine.runtime.loadPackages(["numpy"]);
log(`# numpy loaded in ${Math.round(performance.now() - t)}ms`);
log(">>> import numpy as np; int(np.arange(10).sum())");
const n = machine.run("import numpy as np; int(np.arange(10).sum())");
log(String(n));
gateReport(s === 4950 && n === 45);
} catch (e) {
st.textContent = "Failed";
log("Error: " + e);
gateReport(false);
}
</script>
</body>
</html>