Jizzo commited on
Commit
fa0672e
·
verified ·
1 Parent(s): aa93fff

Create templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +41 -0
templates/index.html ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="de">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Deutsch KI Chatbot</title>
6
+ <link rel="stylesheet" href="/static/style.css">
7
+ </head>
8
+ <body>
9
+ <div class="container">
10
+ <h1>💬 Deutschsprachiger KI-Chatbot</h1>
11
+ <div id="chatbox"></div>
12
+ <form id="chat-form">
13
+ <input type="text" id="user-input" placeholder="Nachricht eingeben..." required>
14
+ <button type="submit">Senden</button>
15
+ </form>
16
+ </div>
17
+
18
+ <script>
19
+ const form = document.getElementById("chat-form");
20
+ const input = document.getElementById("user-input");
21
+ const chatbox = document.getElementById("chatbox");
22
+
23
+ form.addEventListener("submit", async (e) => {
24
+ e.preventDefault();
25
+ const message = input.value;
26
+ chatbox.innerHTML += `<div class="user"><b>Du:</b> ${message}</div>`;
27
+ input.value = "";
28
+
29
+ const response = await fetch("/chat", {
30
+ method: "POST",
31
+ headers: { "Content-Type": "application/json" },
32
+ body: JSON.stringify({ message }),
33
+ });
34
+
35
+ const data = await response.json();
36
+ chatbox.innerHTML += `<div class="bot"><b>Bot:</b> ${data.response}</div>`;
37
+ chatbox.scrollTop = chatbox.scrollHeight;
38
+ });
39
+ </script>
40
+ </body>
41
+ </html>