Here is my HTML code:
<!DOCTYPE html>
<html lang="en" class="light">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ScratchFind</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://pyscript.net/releases/2024.4.1/core.css">
<script type="module" src="https://pyscript.net/releases/2024.4.1/core.js"></script>
<script type="py" src="./main.py" config="./pyscript.json"></script>
</head>
<body>
<!-- Back end -->
<script src="script.js"></script>
<!-- Front end -->
<h1>ScratchFind</h1>
<input id="url" type="text" name="input" placeholder="Paste your URL here">
<input py-click="hello" type="submit" value="Find!">
<h1 id="display"></h1>
<!-- Theme toggle -->
<label class="switch">
<input type="checkbox" onclick="toggleTheme()">
<span class="slider"></span>
</label>
</body>
</html>
and here is my python code:
import requests
from pyscript import document
url = document.querySelector("#url")
display = document.querySelector("#display")
display.innerText = "a"
link = ""
def hello():
link = url.value
display.innerText = link
main.py is working but the function isn't called when I click the button.
I am expecting that when the button is pressed the code inside the function hello works.