-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestpage.html
58 lines (52 loc) · 1.81 KB
/
testpage.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!DOCTYPE html>
<html>
<head>
<title>API Test Page</title>
</head>
<body>
<button id="get-headshot">Get Headshot</button>
<button id="get-resume">Get Resume</button>
<button id="get-text">Get Text</button>
<div id="response"></div>
<script>
const headshotButton = document.getElementById("get-headshot");
const resumeButton = document.getElementById("get-resume");
const textButton = document.getElementById("get-text");
const responseDiv = document.getElementById("response");
headshotButton.addEventListener("click", fetchHeadshot);
resumeButton.addEventListener("click", fetchResume);
textButton.addEventListener("click", fetchText);
function fetchHeadshot() {
fetch("http://localhost:3000/headshot")
.then((response) => response.blob())
.then((data) => {
const imageUrl = URL.createObjectURL(data);
const image = document.createElement("img");
image.src = imageUrl;
responseDiv.innerHTML = "";
responseDiv.appendChild(image);
});
}
function fetchResume() {
fetch("http://localhost:3000/resume")
.then((response) => response.blob())
.then((data) => {
const pdfUrl = URL.createObjectURL(data);
const pdfFrame = document.createElement("embed");
pdfFrame.src = pdfUrl;
pdfFrame.width = "800";
pdfFrame.height = "600";
responseDiv.innerHTML = "";
responseDiv.appendChild(pdfFrame);
});
}
function fetchText() {
fetch("http://localhost:3000/text")
.then((response) => response.text())
.then((data) => {
responseDiv.innerText = data;
});
}
</script>
</body>
</html>