This repository was archived by the owner on Mar 14, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
86 lines (79 loc) · 2.42 KB
/
index.html
File metadata and controls
86 lines (79 loc) · 2.42 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Disaster AI Chatbot</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
text-align: center;
padding: 20px;
}
.chat-container {
width: 60%;
max-width: 500px;
background: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
margin: auto;
}
input {
width: 80%;
padding: 10px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
padding: 10px 20px;
background: #007bff;
color: white;
border: none;
cursor: pointer;
}
button:hover {
background: #0056b3;
}
.response {
margin-top: 20px;
font-size: 16px;
color: #333;
}
</style>
</head>
<body>
<div class="chat-container">
<h2>Disaster AI Chatbot</h2>
<input type="text" id="userInput" placeholder="Ask a question..." />
<button onclick="sendMessage()">Send</button>
<p class="response" id="botResponse"></p>
</div>
<script>
async function sendMessage() {
let userMessage = document.getElementById("userInput").value;
let responseField = document.getElementById("botResponse");
if (!userMessage) {
responseField.innerHTML = "Please enter a message!";
return;
}
responseField.innerHTML = "Thinking...";
try {
let response = await fetch("https://disaster-chatbot.onrender.com/chat", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ message: userMessage })
});
let data = await response.json();
responseField.innerHTML = `<strong>Bot:</strong> ${data.response}`;
} catch (error) {
responseField.innerHTML = "Error connecting to the server.";
}
}
</script>
</body>
</html>