forked from opengovsg/pdf2md
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
47 lines (40 loc) · 1.14 KB
/
index.html
File metadata and controls
47 lines (40 loc) · 1.14 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>PDF to Markdown Converter</title>
<script>
async function handleFileUpload() {
const fileInput = document.getElementById('file');
const file = fileInput.files[0];
if (!file) {
alert("No file selected.");
return;
}
const formData = new FormData();
formData.append('file', file);
try {
const response = await fetch('http://localhost:80/api/convertPdfToMd', {
method: 'POST',
body: formData
});
if (response.status !== 200) {
alert(`Failed to upload: ${response.statusText}`);
return;
}
const result = await response.json();
document.getElementById('output').textContent = result.markdown;
} catch (err) {
alert(`An error occurred: ${err}`);
}
}
</script>
</head>
<body>
<h1>PDF to Markdown Converter</h1>
<input type="file" id="file" />
<button onclick="handleFileUpload()">Upload and Convert</button>
<h2>Converted Markdown:</h2>
<pre id="output"></pre>
</body>
</html>