This repository has been archived by the owner on Feb 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
94 lines (83 loc) · 2.34 KB
/
index.html
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Translation App</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/css/bootstrap.min.css">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700&display=swap" rel="stylesheet">
<style>
body {
background: linear-gradient(to bottom right, #ff0066, #993399);
font-family: 'Roboto', sans-serif;
}
.container {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.white-box {
background-color: white;
border-radius: 10px;
padding: 20px;
max-width: 800px;
width: 100%;
}
.text-box {
width: 100%;
height: 200px;
resize: none;
}
#translate-btn {
margin-top: 10px;
}
#output {
margin-top: 20px;
}
</style>
</head>
<body>
<div class="container">
<div class="white-box">
<h1>Translation App</h1>
<div class="row">
<div class="col">
<label for="input" class="form-label">Input</label>
<textarea class="form-control text-box" id="input"></textarea>
</div>
<div class="col">
<label for="output" class="form-label">Output</label>
<textarea class="form-control text-box" id="output" readonly></textarea>
</div>
</div>
<button id="translate-btn" class="btn btn-primary">Translate</button>
</div>
</div>
<script>
document.getElementById("translate-btn").addEventListener("click", function () {
var inputText = document.getElementById("input").value;
var outputText = document.getElementById("output");
outputText.value = "Translating...";
// Send a POST request to the server
fetch("http://127.0.0.1:5000", {
method: "POST",
body: inputText,
headers: {
"Content-Type": "application/text",
},
})
.then(function (response) {
return response.text();
})
.then(function (translatedText) {
outputText.value = translatedText;
})
.catch(function (error) {
console.log("Error:", error);
outputText.value = "Error occurred.";
});
});
</script>
</body>
</html>