-
Notifications
You must be signed in to change notification settings - Fork 39
/
popup.html
41 lines (38 loc) · 1.26 KB
/
popup.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>PyScript Demo 1</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<py-config>
[[runtimes]]
src = "runtime/pyodide.js"
name = "pyodide-0.21.3"
lang = "python"
</py-config>
<link rel="icon" type="icons/png" href="/icon-128.png" />
<link rel="stylesheet" href="popup.css" />
<link rel="stylesheet" href="runtime/pyscript.css" />
<script defer src="runtime/pyscript.js"></script>
</head>
<body>
<h2>Hello World!</h2>
<h4 id="datetime"></h4>
<!-- Python code below is intentionally left-aligned to utilise full width -->
<py-script>
from js import document as popup # DOM for this popup page
from datetime import datetime
# Use print to update the popup
print("This is the current date and time in ISO8601 format, courtesy of Python and PyScript.<br><br>")
# Update an element in the popup directly
insert_content = popup.getElementById('datetime')
insert_content.innerHTML = f"<i>{datetime.now().isoformat()}</i>"
</py-script>
<py-repl>
text = "This is a REPL session.<br>"
text += "You can add several lines of Python<br>"
text += "Then just press Shift-ENTER to run!"
print(text.upper())
</py-repl>
</body>
</html>