-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
37 lines (32 loc) · 1.03 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
<h1>PDF Summary Generator</h1>
<form action="/upload" method="post" enctype="multipart/form-data">
<input type="file" name="pdf" accept=".pdf">
<button type="submit">Generate Summary</button>
</form>
<div id="summary"></div>
<script>
// Handle form submission
document.querySelector("form").addEventListener("submit", (event) => {
// Prevent default form submission behavior
event.preventDefault();
// Get the uploaded file
const file = document.querySelector("input[type=file]").files[0];
// Create a FormData object to send the file in the request
const formData = new FormData();
formData.append("pdf", file);
// Make an AJAX request to the /upload route
fetch("/upload", {
method: "POST",
body: formData,
})
.then((response) => response.text())
.then((summary) => {
// Update the summary in the page
document.querySelector("#summary").innerHTML = summary;
})
.catch((error) => {
// Handle error
alert(error.message);
});
});
</script>