Spaces:
Running
Running
Update index.html
Browse files- index.html +81 -19
index.html
CHANGED
@@ -1,19 +1,81 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Headline Generator</title>
|
7 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet">
|
8 |
+
<style>
|
9 |
+
/* Styles remain unchanged */
|
10 |
+
</style>
|
11 |
+
</head>
|
12 |
+
<body>
|
13 |
+
<!-- Navbar and container structure remains unchanged -->
|
14 |
+
|
15 |
+
<div class="container">
|
16 |
+
<h1>Headline Generator</h1>
|
17 |
+
<p>Effortlessly generate eye-catching headlines with AI. All we need is a topic from you.</p>
|
18 |
+
|
19 |
+
<div class="headline-box">
|
20 |
+
<h2>AI-Powered Headline Generator</h2>
|
21 |
+
<form id="headline-form">
|
22 |
+
<textarea name="article" id="topic-input" placeholder="Enter your article here" rows="8" required></textarea>
|
23 |
+
<button type="submit">Generate</button>
|
24 |
+
</form>
|
25 |
+
</div>
|
26 |
+
|
27 |
+
<div class="predicted-headline" id="predicted-headline">
|
28 |
+
Your generated headline will appear here!
|
29 |
+
</div>
|
30 |
+
|
31 |
+
<!-- SEO score section remains unchanged -->
|
32 |
+
</div>
|
33 |
+
|
34 |
+
<script>
|
35 |
+
document.getElementById('headline-form').addEventListener('submit', function(event) {
|
36 |
+
event.preventDefault(); // Prevent default form submission
|
37 |
+
|
38 |
+
const article = document.getElementById('topic-input').value;
|
39 |
+
if (!article) {
|
40 |
+
alert('Please enter an article.');
|
41 |
+
return;
|
42 |
+
}
|
43 |
+
|
44 |
+
const apiKey = 'YOUR_API_KEY_HERE'; // Replace with your actual Gemini API key
|
45 |
+
const headers = {
|
46 |
+
'Content-Type': 'application/json',
|
47 |
+
'Authorization': 'Bearer ' + apiKey
|
48 |
+
};
|
49 |
+
|
50 |
+
const data = {
|
51 |
+
"prompt": {
|
52 |
+
"text": `Generate a headline for the following article:\n\n${article}`
|
53 |
+
},
|
54 |
+
"temperature": 0.7,
|
55 |
+
"maxOutputTokens": 128
|
56 |
+
};
|
57 |
+
|
58 |
+
fetch('https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent', {
|
59 |
+
method: 'POST',
|
60 |
+
headers: headers,
|
61 |
+
body: JSON.stringify(data)
|
62 |
+
})
|
63 |
+
.then(response => {
|
64 |
+
if (!response.ok) {
|
65 |
+
throw new Error('Network response was not ok');
|
66 |
+
}
|
67 |
+
return response.json();
|
68 |
+
})
|
69 |
+
.then(data => {
|
70 |
+
const headline = data.results[0].candidates[0].output.text;
|
71 |
+
document.getElementById('predicted-headline').innerText = headline;
|
72 |
+
document.getElementById('predicted-headline').classList.add('visible');
|
73 |
+
})
|
74 |
+
.catch(error => {
|
75 |
+
console.error('Error generating headline:', error);
|
76 |
+
alert('An error occurred while generating the headline.');
|
77 |
+
});
|
78 |
+
});
|
79 |
+
</script>
|
80 |
+
</body>
|
81 |
+
</html>
|