admin08077 commited on
Commit
0b9b881
·
verified ·
1 Parent(s): 29d65cb

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +36 -18
index.html CHANGED
@@ -1,19 +1,37 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </html>
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Pyodide Example</title>
6
+ <script src="https://cdn.jsdelivr.net/pyodide/v0.23.4/full/pyodide.js"></script>
7
+ </head>
8
+ <body>
9
+ <textarea id="python-code" rows="10" cols="50">
10
+ # Sample Python Code
11
+ import math
12
+
13
+ def compute_circle_area(radius):
14
+ return math.pi * radius ** 2
15
+
16
+ print(compute_circle_area(5))
17
+ </textarea>
18
+ <br>
19
+ <button onclick="runPython()">Run Python</button>
20
+ <pre id="output"></pre>
21
+
22
+ <script>
23
+ let pyodideReadyPromise = loadPyodide();
24
+
25
+ async function runPython() {
26
+ await pyodideReadyPromise;
27
+ const code = document.getElementById("python-code").value;
28
+ try {
29
+ let output = await pyodide.runPythonAsync(code);
30
+ document.getElementById("output").textContent = output;
31
+ } catch (err) {
32
+ document.getElementById("output").textContent = err;
33
+ }
34
+ }
35
+ </script>
36
+ </body>
37
  </html>