Spaces:
Runtime error
Runtime error
Update index.html
Browse files- index.html +33 -0
index.html
CHANGED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<html lang="en">
|
2 |
+
<head>
|
3 |
+
<meta charset="UTF-8">
|
4 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
5 |
+
<title>Headline Predictor</title>
|
6 |
+
</head>
|
7 |
+
<body>
|
8 |
+
<h1>Headline Predictor</h1>
|
9 |
+
<form id="article-form">
|
10 |
+
<label for="article">Article:</label><br>
|
11 |
+
<textarea id="article" name="article" rows="10" cols="50"></textarea><br><br>
|
12 |
+
<button type="submit">Predict Headline</button>
|
13 |
+
</form>
|
14 |
+
<h2>Predicted Headline:</h2>
|
15 |
+
<p id="headline"></p>
|
16 |
+
|
17 |
+
<script>
|
18 |
+
document.getElementById('article-form').addEventListener('submit', async function(e) {
|
19 |
+
e.preventDefault();
|
20 |
+
const article = document.getElementById('article').value;
|
21 |
+
const response = await fetch('/predict', {
|
22 |
+
method: 'POST',
|
23 |
+
headers: {
|
24 |
+
'Content-Type': 'application/x-www-form-urlencoded',
|
25 |
+
},
|
26 |
+
body: new URLSearchParams({ article }),
|
27 |
+
});
|
28 |
+
const result = await response.json();
|
29 |
+
document.getElementById('headline').innerText = result.headline || result.error;
|
30 |
+
});
|
31 |
+
</script>
|
32 |
+
</body>
|
33 |
+
</html>
|