-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqa.html
104 lines (95 loc) · 2.32 KB
/
qa.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PDF Quick Reader - Q&A</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<style>
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: flex-start;
height: 100vh;
}
#pdfViewer {
width: 40%;
height: 100vh;
border-right: 2px solid #ccc;
}
#qaSection {
width: 60%;
padding: 20px;
}
#question {
margin-bottom: 20px;
}
#response {
border: 2px solid #ccc;
border-radius: 5px;
padding: 20px;
box-sizing: border-box;
height: 50vh;
overflow-y: auto;
}
#footer {
position: fixed;
bottom: 10px;
width: 100%;
text-align: center;
font-size: 12px;
color: #666;
}
</style>
</head>
<body>
<div id="pdfViewer">
<!-- PDF Viewer Goes Here -->
<iframe
id="pdfIframe"
src=""
width="100%"
height="100%"
frameborder="0"
></iframe>
</div>
<div id="qaSection">
<div id="question">
<h2>Question</h2>
<input
type="text"
id="query"
name="query"
placeholder="Enter your query"
style="width: 80%; margin-right: 10px"
/>
<button onclick="search()">Search</button>
</div>
<div id="response">
<!-- Responses Go Here -->
</div>
</div>
<div id="footer">Made by Hao</div>
<script>
$(document).ready(function () {
$.get("/upload", function (data) {
if (data && data.length > 0) {
var latestPdf = "/pdf_viewer/" + data[0]; // 使用新的路由
$("#pdfIframe").attr("src", latestPdf);
} else {
console.log("No PDF files found.");
}
});
});
function search() {
var query = $("#query").val();
$.post("/search", { query: query }, function (data) {
$("#response").html(data);
});
}
</script>
</body>
</html>