-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
52 lines (45 loc) · 1.4 KB
/
index.html
File metadata and controls
52 lines (45 loc) · 1.4 KB
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
<!-- public/index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Save Text</title>
<style>
body { font-family: Arial, sans-serif; background-color: #282c34; color: white; text-align: center; padding: 20px; }
textarea { width: 80%; height: 200px; margin: 10px; }
button { padding: 10px 20px; }
</style>
</head>
<body>
<h1>Save Text</h1>
<form id="save-form">
<textarea id="text-input" placeholder="Start writing..." required></textarea>
<br>
<button type="submit">Submit</button>
</form>
<script>
document.getElementById('save-form').addEventListener('submit', async (e) => {
e.preventDefault();
const text = document.getElementById('text-input').value;
try {
const response = await fetch('/save', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ text }),
});
if (!response.ok) {
throw new Error('Network response was not ok');
}
const result = await response.json();
alert('Paste saved! URL: ' + result.url);
} catch (error) {
console.error('Error saving paste:', error);
alert('An error occurred while saving your paste. Please try again.');
}
});
</script>
</body>
</html>