NanobotzAI commited on
Commit
6e314c7
·
verified ·
1 Parent(s): 94f2884

Create index.html

Browse files
Files changed (1) hide show
  1. index.html +62 -0
index.html ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>PDF-Based Chatbot</title>
7
+ <style>
8
+ body { font-family: Arial, sans-serif; margin: 20px; text-align: center; }
9
+ #chat-container { max-width: 600px; margin: auto; }
10
+ input, button { padding: 10px; margin: 10px; }
11
+ #response { margin-top: 20px; white-space: pre-wrap; }
12
+ </style>
13
+ </head>
14
+ <body>
15
+
16
+ <h2>Chat with Your PDF</h2>
17
+
18
+ <!-- PDF Upload -->
19
+ <input type="file" id="pdfInput">
20
+ <button onclick="uploadPDF()">Upload PDF</button>
21
+
22
+ <hr>
23
+
24
+ <!-- Chat Section -->
25
+ <div id="chat-container">
26
+ <input type="text" id="userMessage" placeholder="Ask a question">
27
+ <button onclick="sendMessage()">Send</button>
28
+ <p id="response"></p>
29
+ </div>
30
+
31
+ <script>
32
+ function uploadPDF() {
33
+ let fileInput = document.getElementById('pdfInput');
34
+ if (!fileInput.files.length) {
35
+ alert("Please select a PDF file.");
36
+ return;
37
+ }
38
+
39
+ let filePath = fileInput.files[0].name;
40
+
41
+ fetch(`/upload_pdf/?file_path=${filePath}`, { method: "POST" })
42
+ .then(response => response.json())
43
+ .then(data => alert(data.message))
44
+ .catch(error => console.error("Error uploading PDF:", error));
45
+ }
46
+
47
+ function sendMessage() {
48
+ let userMessage = document.getElementById('userMessage').value;
49
+ if (!userMessage.trim()) {
50
+ alert("Please enter a message.");
51
+ return;
52
+ }
53
+
54
+ fetch(`/chat/?msg=${encodeURIComponent(userMessage)}`)
55
+ .then(response => response.json())
56
+ .then(data => document.getElementById('response').innerText = "AI: " + data.response)
57
+ .catch(error => console.error("Error fetching response:", error));
58
+ }
59
+ </script>
60
+
61
+ </body>
62
+ </html>