mirror of
https://github.com/System-End/self-learning-ai-website.git
synced 2026-04-19 16:38:19 +00:00
Update scripts.js
This commit is contained in:
parent
5d2082669a
commit
f335837881
1 changed files with 21 additions and 7 deletions
28
scripts.js
28
scripts.js
|
|
@ -1,6 +1,6 @@
|
|||
document.addEventListener("DOMContentLoaded", function () {
|
||||
// Fetch and display content from teamparadise1165.com
|
||||
fetch("https://teamparadise1165.com")
|
||||
fetch("http://your-ec2-public-dns:5000/scrape")
|
||||
.then((response) => response.text())
|
||||
.then((data) => {
|
||||
document.getElementById("content-container").innerHTML = data;
|
||||
|
|
@ -24,12 +24,26 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||
chatOutput.appendChild(userMessage);
|
||||
chatInput.value = "";
|
||||
|
||||
// Simulate AI response
|
||||
setTimeout(() => {
|
||||
const aiMessage = document.createElement("div");
|
||||
aiMessage.textContent = "AI: This is a simulated response.";
|
||||
chatOutput.appendChild(aiMessage);
|
||||
}, 1000);
|
||||
// Send message to backend server
|
||||
fetch("http://your-ec2-public-dns:5000/chat", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ prompt: message }),
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
const aiMessage = document.createElement("div");
|
||||
aiMessage.textContent = "AI: " + data;
|
||||
chatOutput.appendChild(aiMessage);
|
||||
})
|
||||
.catch((error) => {
|
||||
const aiMessage = document.createElement("div");
|
||||
aiMessage.textContent = "Failed to get response from AI.";
|
||||
chatOutput.appendChild(aiMessage);
|
||||
console.error("Error:", error);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue