Spaces:
Sleeping
Sleeping
| <html> | |
| <head> | |
| <title>Rust Hello App</title> | |
| </head> | |
| <body> | |
| <h2>Rust + Flask + JS Fetch (Local HTML + HF Backend)</h2> | |
| <label for="name">Enter your name:</label> | |
| <input type="text" id="name" name="name"> | |
| <button onclick="sendData()">Say Hello</button> | |
| <p id="result" style="font-weight:bold;"></p> | |
| <script> | |
| function sendData() { | |
| const name = document.getElementById('name').value; | |
| fetch("https://<your-hf-space>.hf.space/process", { | |
| method: "POST", | |
| headers: { | |
| "Content-Type": "application/x-www-form-urlencoded", | |
| }, | |
| body: name=${encodeURIComponent(name)} | |
| }) | |
| .then(response => response.text()) | |
| .then(data => { | |
| document.getElementById("result").innerText = data; | |
| }) | |
| .catch(error => { | |
| document.getElementById("result").innerText = "Error: " + error; | |
| }); | |
| } | |
| </script> | |
| </body> | |
| </html> |