-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmika_cat.html
47 lines (45 loc) · 1.88 KB
/
mika_cat.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
36
37
38
39
40
41
42
43
44
45
46
47
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/pyodide/v0.19.0/full/pyodide.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
<style>
.game-screen {
font-family: monospace;
}
</style>
</head>
<body>
Some text.<br>
<script type="text/javascript">
async function main(){
let pyodide = await loadPyodide({
indexURL : "https://cdn.jsdelivr.net/pyodide/v0.19.0/full/"
});
await pyodide.loadPackage("attrs");
await pyodide.runPythonAsync(`
from pyodide.http import pyfetch
from asyncio import gather
from os import mkdir
from random import randint
async def fetch_py(filename):
print(f"fetching py file {filename}")
response = await pyfetch(filename + "?rnd=" + str(randint(1, 99999999)))
with open(filename, "wb") as f:
f.write(await response.bytes())
mkdir("styleml")
py_files = "mika_svgui.py, styleml_glyph_exts.py, mika_screen.py, styleml_mika_exts.py, utilities.py, ./styleml/convenient_argument.py, ./styleml/core.py, ./styleml/macro_ext.py, ./styleml/portal_ext.py"
py_files = py_files.split(", ")
await gather(*[fetch_py(fn) for fn in py_files])
`)
pyodide.runPython(await (await fetch("mika_cat.py" + "?rnd=" + Math.random())).text());
}
main();
</script>
<textarea id="sty-text"></textarea>
<button id="show-sty">update</button>
<button id="clear-sty">clear</button>
<button id="interrupt-sty-animation">interrupt</button>
<br>
</body>
</html>