Spaces:
Sleeping
Sleeping
Update index.html
Browse files- index.html +19 -44
index.html
CHANGED
|
@@ -1,45 +1,20 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
video.srcObject = stream;
|
| 9 |
-
} catch (err) {
|
| 10 |
-
alert("Could not access camera/mic: " + err.message);
|
| 11 |
-
}
|
| 12 |
-
}
|
| 13 |
-
|
| 14 |
-
async function askBot(message) {
|
| 15 |
-
const res = await fetch("/ask", {
|
| 16 |
-
method: "POST",
|
| 17 |
-
headers: { "Content-Type": "application/json" },
|
| 18 |
-
body: JSON.stringify({ message })
|
| 19 |
-
});
|
| 20 |
-
const data = await res.json();
|
| 21 |
-
return data.response;
|
| 22 |
-
}
|
| 23 |
-
|
| 24 |
-
function appendMessage(sender, text) {
|
| 25 |
-
const msg = document.createElement("div");
|
| 26 |
-
msg.textContent = `${sender}: ${text}`;
|
| 27 |
-
messages.appendChild(msg);
|
| 28 |
-
messages.scrollTop = messages.scrollHeight;
|
| 29 |
-
}
|
| 30 |
-
|
| 31 |
-
document.getElementById("startInterview").addEventListener("click", async () => {
|
| 32 |
-
await startCamera();
|
| 33 |
-
const question = await askBot("Start the interview.");
|
| 34 |
-
appendMessage("Interviewer", question);
|
| 35 |
-
});
|
| 36 |
-
|
| 37 |
-
async function sendAnswer() {
|
| 38 |
-
const answer = input.value.trim();
|
| 39 |
-
if (!answer) return;
|
| 40 |
-
appendMessage("You", answer);
|
| 41 |
-
input.value = "";
|
| 42 |
-
|
| 43 |
-
const nextQuestion = await askBot(answer);
|
| 44 |
-
appendMessage("Interviewer", nextQuestion);
|
| 45 |
-
}
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<title>AI Interview Bot</title>
|
| 6 |
+
<link rel="stylesheet" href="static/style.css" />
|
| 7 |
+
</head>
|
| 8 |
+
<body>
|
| 9 |
+
<h1>🎤 AI Interview Bot</h1>
|
| 10 |
+
<video id="localVideo" autoplay muted playsinline></video>
|
| 11 |
+
<div id="chat">
|
| 12 |
+
<div id="messages"></div>
|
| 13 |
+
<input id="userInput" placeholder="Type your answer..." />
|
| 14 |
+
<button onclick="sendAnswer()">Send</button>
|
| 15 |
+
</div>
|
| 16 |
+
<button id="startInterview">Start Interview</button>
|
| 17 |
|
| 18 |
+
<script src="static/interview.js"></script>
|
| 19 |
+
</body>
|
| 20 |
+
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|