INIT
This commit is contained in:
parent
0ee6440ea3
commit
52dc67adc1
8 changed files with 174 additions and 0 deletions
45
templates/index.html
Normal file
45
templates/index.html
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>PDF Splitter</title>
|
||||
<link rel="shortcut icon" href="/static/icons/filetype-pdf.svg" type="image/x-icon">
|
||||
</head>
|
||||
<body>
|
||||
<h1>PDF Splitter</h1>
|
||||
<input type="file" id="pdfFile" accept=".pdf"><br>
|
||||
<button onclick="uploadPDF()">Split PDF into individual pages</button>
|
||||
<div id="output"></div>
|
||||
|
||||
<script>
|
||||
function downloadURI(uri, name) {
|
||||
var link = document.createElement("a");
|
||||
link.download = name;
|
||||
link.href = uri;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
delete link;
|
||||
}
|
||||
|
||||
function uploadPDF() {
|
||||
const fileInput = document.getElementById('pdfFile');
|
||||
const file = fileInput.files[0];
|
||||
const formData = new FormData();
|
||||
formData.append('pdf', file);
|
||||
|
||||
const backendURL = '/split';
|
||||
|
||||
fetch(backendURL, {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
console.debug("data from Backend: ", data)
|
||||
downloadURI(data["url"], data["name"]);
|
||||
})
|
||||
.catch(error => console.error(error));
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue