1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Hello World</title>
- <style>
- body {
- display: flex;
- justify-content: center;
- align-items: center;
- height: 100vh;
- margin: 0;
- font-family: Arial, sans-serif;
- }
- </style>
- </head>
- <body>
- <div>
- <form id="myForm">
- <input type="text" id="myInput" placeholder="Enter text">
- <button type="submit">Send</button>
- </form>
- <p id="response">Enter a name in the input box and click send</p>
- </div>
-
- <script>
- document.getElementById('myForm').addEventListener('submit', function(event) {
- event.preventDefault();
- var inputValue = document.getElementById('myInput').value;
- fetch('/api/hello?name=' + encodeURIComponent(inputValue))
- .then(response => response.text())
- .then(data => {
- document.getElementById('response').innerText = data;
- })
- .catch(error => {
- console.error('Error:', error);
- });
- });
- </script>
- </body>
- </html>
|