MedhaCodes commited on
Commit
655a07e
·
verified ·
1 Parent(s): 65b318a

Upload 2 files

Browse files
Files changed (2) hide show
  1. static/script.js +36 -0
  2. static/style.css +101 -0
static/script.js ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ document.getElementById("get-answer").addEventListener("click", async () => {
2
+ const context = document.getElementById("context").value.trim();
3
+ const questions = document.getElementById("questions").value.trim();
4
+ const output = document.getElementById("answer-box");
5
+ const history = document.getElementById("history-list");
6
+
7
+ output.textContent = "⏳ Generating answers...";
8
+
9
+ const res = await fetch("/get_answer", {
10
+ method: "POST",
11
+ headers: {"Content-Type": "application/json"},
12
+ body: JSON.stringify({ context, questions })
13
+ });
14
+
15
+ const data = await res.json();
16
+
17
+ if (data.error) {
18
+ output.textContent = "⚠️ " + data.error;
19
+ return;
20
+ }
21
+
22
+ let text = "";
23
+ data.results.forEach((r, i) => {
24
+ text += `Q${i + 1}: ${r.question}\nAnswer: ${r.answer}\nConfidence: ${r.score}\n${"-".repeat(50)}\n`;
25
+ });
26
+ output.textContent = text;
27
+
28
+ // Add to history
29
+ const li = document.createElement("li");
30
+ li.textContent = questions.replace(/\n/g, " | ");
31
+ history.prepend(li);
32
+ });
33
+
34
+ document.getElementById("toggle-dark").addEventListener("click", () => {
35
+ document.body.classList.toggle("dark-mode");
36
+ });
static/style.css ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ body {
2
+ font-family: "Segoe UI", Roboto, sans-serif;
3
+ background-color: #f8f9fc;
4
+ color: #222;
5
+ margin: 0;
6
+ padding: 0;
7
+ transition: background 0.4s, color 0.4s;
8
+ }
9
+
10
+ .navbar {
11
+ display: flex;
12
+ justify-content: space-between;
13
+ align-items: center;
14
+ background: #4f46e5;
15
+ color: white;
16
+ padding: 12px 30px;
17
+ font-size: 18px;
18
+ box-shadow: 0 2px 10px rgba(0,0,0,0.15);
19
+ }
20
+
21
+ .navbar a {
22
+ color: white;
23
+ margin-left: 20px;
24
+ text-decoration: none;
25
+ }
26
+
27
+ .container {
28
+ max-width: 900px;
29
+ margin: 40px auto;
30
+ padding: 20px;
31
+ }
32
+
33
+ .card {
34
+ background: white;
35
+ border-radius: 15px;
36
+ box-shadow: 0 5px 25px rgba(0,0,0,0.1);
37
+ padding: 30px;
38
+ }
39
+
40
+ .card h2 {
41
+ text-align: center;
42
+ color: #4f46e5;
43
+ }
44
+
45
+ label {
46
+ font-weight: bold;
47
+ display: block;
48
+ margin-top: 20px;
49
+ }
50
+
51
+ textarea {
52
+ width: 100%;
53
+ border-radius: 8px;
54
+ border: 1px solid #ccc;
55
+ padding: 10px;
56
+ font-size: 16px;
57
+ margin-top: 8px;
58
+ resize: vertical;
59
+ min-height: 100px;
60
+ }
61
+
62
+ button {
63
+ display: block;
64
+ margin: 20px auto;
65
+ background: #4f46e5;
66
+ color: white;
67
+ border: none;
68
+ border-radius: 10px;
69
+ padding: 12px 30px;
70
+ font-size: 16px;
71
+ cursor: pointer;
72
+ transition: background 0.3s;
73
+ }
74
+
75
+ button:hover {
76
+ background: #4338ca;
77
+ }
78
+
79
+ pre {
80
+ background: #f1f5f9;
81
+ padding: 15px;
82
+ border-radius: 10px;
83
+ overflow-x: auto;
84
+ }
85
+
86
+ .dark-mode {
87
+ background-color: #181818;
88
+ color: #f1f1f1;
89
+ }
90
+
91
+ .dark-mode .card {
92
+ background-color: #242424;
93
+ }
94
+
95
+ .dark-mode pre {
96
+ background-color: #333;
97
+ }
98
+
99
+ .dark-mode .navbar {
100
+ background-color: #2e2e2e;
101
+ }