Spaces:
Build error
Build error
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Chatbot</title> | |
| <style> | |
| body { | |
| font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; | |
| background-color: #1e1e1e; | |
| color: #f1f1f1; | |
| margin: 20px; | |
| } | |
| h1 { | |
| color: #00bfff; | |
| text-align: center; | |
| } | |
| #chat { | |
| border: 1px solid #444; | |
| background-color: #2e2e2e; | |
| padding: 15px; | |
| width: 100%; | |
| max-width: 1300px; | |
| height: 400px; | |
| overflow-y: auto; | |
| margin-bottom: 20px; | |
| border-radius: 8px; | |
| box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3); | |
| } | |
| #userInput { | |
| width: 80%; | |
| padding: 12px; | |
| background-color: #333; | |
| color: #f1f1f1; | |
| border: 1px solid #555; | |
| border-radius: 4px; | |
| outline: none; | |
| transition: border-color 0.3s ease; | |
| } | |
| #userInput:focus { | |
| border-color: #00bfff; | |
| } | |
| #sendBtn { | |
| padding: 12px 20px; | |
| background-color: #00bfff; | |
| color: #fff; | |
| border: none; | |
| border-radius: 4px; | |
| cursor: pointer; | |
| transition: background-color 0.3s ease; | |
| margin-left: 10px; | |
| } | |
| #sendBtn:hover { | |
| background-color: #009fda; | |
| } | |
| #chat div { | |
| margin: 10px 0; | |
| } | |
| .user-message { | |
| color: #d1d1d1; | |
| text-align: right; | |
| } | |
| .bot-message { | |
| color: #b8e994; | |
| text-align: left; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <h1>Chess♟️Chatbot</h1> | |
| <div id="chat"></div> | |
| <input type="text" id="userInput" placeholder="Type a message..." /> | |
| <button id="sendBtn">Send</button> | |
| <script> | |
| const chatDiv = document.getElementById('chat'); | |
| const userInput = document.getElementById('userInput'); | |
| const sendBtn = document.getElementById('sendBtn'); | |
| sendBtn.addEventListener('click', function() { | |
| const message = userInput.value; | |
| if (message) { | |
| chatDiv.innerHTML += `<div class="user-message">You: ${message}</div>`; | |
| userInput.value = ''; | |
| fetch('/chat', { | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| }, | |
| body: JSON.stringify({ user_message: message }), | |
| }) | |
| .then(response => response.json()) | |
| .then(data => { | |
| chatDiv.innerHTML += `<div class="bot-message">Bot: ${data.bot_response}</div>`; | |
| chatDiv.scrollTop = chatDiv.scrollHeight; // Scroll to the bottom | |
| }) | |
| .catch(error => console.error('Error:', error)); | |
| } | |
| }); | |
| userInput.addEventListener('keypress', function(event) { | |
| if (event.key === 'Enter') { | |
| sendBtn.click(); | |
| } | |
| }); | |
| </script> | |
| </body> | |
| </html> | |