File size: 1,407 Bytes
c1901d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>English to Ukrainian Translator</title>
    <style>
        body { font-family: Arial, sans-serif; text-align: center; padding: 20px; }
        textarea { width: 80%; height: 100px; margin: 10px; }
        button { padding: 10px 20px; background: blue; color: white; border: none; cursor: pointer; }
        #result { margin-top: 20px; font-size: 18px; font-weight: bold; }
    </style>
</head>
<body>
    <h1>English to Ukrainian Translator</h1>
    <textarea id="inputText" placeholder="Enter English text..."></textarea>
    <br>
    <button onclick="translateText()">Translate</button>
    <div id="result"></div>

    <script>
        function translateText() {
            let text = document.getElementById("inputText").value;
            if (!text) return;

            fetch("/translate", {
                method: "POST",
                headers: { "Content-Type": "application/json" },
                body: JSON.stringify({ text: text })
            })
            .then(response => response.json())
            .then(data => {
                document.getElementById("result").innerText = "Translation: " + data.translation;
            })
            .catch(error => console.error("Error:", error));
        }
    </script>
</body>
</html>