Spaces:
Sleeping
Sleeping
babu commited on
Create templates/index.html
Browse files- templates/index.html +59 -0
templates/index.html
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html>
|
| 3 |
+
<head>
|
| 4 |
+
<title>SLM Demo</title>
|
| 5 |
+
<style>
|
| 6 |
+
body { font-family: Arial, sans-serif; text-align: center; margin-top: 50px; background-color: #f4f4f9; }
|
| 7 |
+
h2 { color: #333; }
|
| 8 |
+
input { width: 60%; padding: 15px; font-size: 18px; border: 2px solid #ccc; border-radius: 8px; margin-bottom: 20px; }
|
| 9 |
+
button { padding: 15px 25px; font-size: 20px; margin: 10px; border: none; border-radius: 8px; cursor: pointer; }
|
| 10 |
+
.submit-btn { background-color: #4CAF50; color: white; }
|
| 11 |
+
.clear-btn { background-color: #f44336; color: white; }
|
| 12 |
+
#result { margin-top: 30px; font-size: 20px; color: #222; white-space: pre-line; }
|
| 13 |
+
</style>
|
| 14 |
+
</head>
|
| 15 |
+
<body>
|
| 16 |
+
<h2>Sentence Generator 🔮</h2>
|
| 17 |
+
<input type="text" id="phrase" placeholder="Enter phrase (e.g. quiet village)">
|
| 18 |
+
<br>
|
| 19 |
+
<button class="submit-btn" onclick="generate()">✅ Submit</button>
|
| 20 |
+
<button class="clear-btn" onclick="clearBox()">🧹 Clear</button>
|
| 21 |
+
|
| 22 |
+
<p id="result"></p>
|
| 23 |
+
|
| 24 |
+
<script>
|
| 25 |
+
async function generate() {
|
| 26 |
+
const phrase = document.getElementById("phrase").value;
|
| 27 |
+
if (!phrase) {
|
| 28 |
+
document.getElementById("result").innerText = "⚠️ Please enter a phrase first.";
|
| 29 |
+
return;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
document.getElementById("result").innerText = "⏳ Generating...";
|
| 33 |
+
|
| 34 |
+
try {
|
| 35 |
+
const response = await fetch("/frontend_generate", {
|
| 36 |
+
method: "POST",
|
| 37 |
+
headers: { "Content-Type": "application/json" },
|
| 38 |
+
body: JSON.stringify({ phrase })
|
| 39 |
+
});
|
| 40 |
+
|
| 41 |
+
if (!response.ok) {
|
| 42 |
+
throw new Error("Server error: " + response.status);
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
const data = await response.json();
|
| 46 |
+
document.getElementById("result").innerText =
|
| 47 |
+
"👉 Input: " + data.input + "\n✨ Output: " + data.output;
|
| 48 |
+
} catch (err) {
|
| 49 |
+
document.getElementById("result").innerText = "❌ Error: " + err.message;
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
function clearBox() {
|
| 54 |
+
document.getElementById("phrase").value = "";
|
| 55 |
+
document.getElementById("result").innerText = "";
|
| 56 |
+
}
|
| 57 |
+
</script>
|
| 58 |
+
</body>
|
| 59 |
+
</html>
|