-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathif_else_in_pyscript.html
More file actions
28 lines (25 loc) · 988 Bytes
/
if_else_in_pyscript.html
File metadata and controls
28 lines (25 loc) · 988 Bytes
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
<!DOCTYPE html>
<html>
<head>
<!-- <link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" /> -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
</head>
<body>
<div class="container text-center p-5">
<h1>Input and Output</h1>
<input type="number" id="test-input"/>
<button id="test-button" pys-onclick="my_function">Click me</button>
<p id="test-output" class="p-3"></p>
<py-script>
def my_function(*args, **kwargs):
test_number = Element("test-input").element.value
if int(test_number)%2==0:
Element("test-output").element.innerHTML = "Even"
else:
Element("test-output").element.innerHTML = "Odd"
</py-script>
</div>
</body>
</html>