-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
61 lines (45 loc) · 1.62 KB
/
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
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
<!doctype html>
<html>
<head>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://unpkg.com/[email protected]/js/jquery.terminal.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/css/jquery.terminal.min.css"/>
<script src="https://cdn.jsdelivr.net/pyodide/v0.23.3/full/pyodide.js"></script>
</head>
<style>
body {
background-color: black;
}
</style>
<body>
<script>
async function main() {
term = $("body").terminal({
dockerfile_generator: async function(config, ...args) {
let pyodide = await pyodideReadyPromise;
output = pyodide.runPython(
`dockerfile_generator.main.rendered_Dockerfile(config="${config}", params=["${args.join('", "')}"])`
)
this.echo(output)
},
},
{
processArguments : false,
checkArity: false,
greetings: 'Dockerfile generator (via jQuery Terminal https://terminal.jcubic.pl/ and Pyodide https://pyodide.org). '
});
window.term = term;
term.ready = Promise.resolve();
async function getPyodide() {
let pyodide = await loadPyodide();
await pyodide.loadPackage("micropip");
const micropip = pyodide.pyimport("micropip");
await micropip.install("dockerfile_generator");
pyodide.runPython('import dockerfile_generator.main')
return pyodide;
}
let pyodideReadyPromise = getPyodide();
}
window.console_ready = main();
</script>
</html>