Spaces:
Sleeping
Sleeping
Delete index.html
Browse files- index.html +0 -83
index.html
DELETED
|
@@ -1,83 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="ru">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8">
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>AI Chat App</title>
|
| 7 |
-
<style>
|
| 8 |
-
/* Простой и современный стиль */
|
| 9 |
-
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background-color: #f4f4f9; display: flex; justify-content: center; height: 100vh; margin: 0; }
|
| 10 |
-
.chat-container { width: 100%; max-width: 600px; background: white; display: flex; flex-direction: column; box-shadow: 0 4px 10px rgba(0,0,0,0.1); height: 100vh; }
|
| 11 |
-
.header { padding: 20px; background: #2b2d42; color: white; text-align: center; font-weight: bold; }
|
| 12 |
-
.messages { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
|
| 13 |
-
.message { padding: 10px 15px; border-radius: 15px; max-width: 80%; line-height: 1.4; }
|
| 14 |
-
.message.user { align-self: flex-end; background: #3a86ff; color: white; border-bottom-right-radius: 2px; }
|
| 15 |
-
.message.assistant { align-self: flex-start; background: #e9ecef; color: #333; border-bottom-left-radius: 2px; }
|
| 16 |
-
.input-area { padding: 20px; border-top: 1px solid #ddd; display: flex; gap: 10px; background: white; }
|
| 17 |
-
input { flex: 1; padding: 12px; border: 1px solid #ddd; border-radius: 8px; outline: none; }
|
| 18 |
-
button { padding: 12px 20px; background: #2b2d42; color: white; border: none; border-radius: 8px; cursor: pointer; transition: 0.2s; }
|
| 19 |
-
button:hover { background: #3d405b; }
|
| 20 |
-
button:disabled { background: #ccc; }
|
| 21 |
-
</style>
|
| 22 |
-
</head>
|
| 23 |
-
<body>
|
| 24 |
-
|
| 25 |
-
<div class="chat-container">
|
| 26 |
-
<div class="header">Supabase AI Chat</div>
|
| 27 |
-
<div class="messages" id="messages">
|
| 28 |
-
<!-- Сообщения появятся здесь -->
|
| 29 |
-
</div>
|
| 30 |
-
<div class="input-area">
|
| 31 |
-
<input type="text" id="userInput" placeholder="Напишите сообщение..." onkeypress="handleEnter(event)">
|
| 32 |
-
<button onclick="sendMessage()" id="sendBtn">Отправить</button>
|
| 33 |
-
</div>
|
| 34 |
-
</div>
|
| 35 |
-
|
| 36 |
-
<script>
|
| 37 |
-
// Простой ID пользователя для теста (в реальности нужен логин)
|
| 38 |
-
const userEmail = "user_" + Math.floor(Math.random() * 1000) + "@test.com";
|
| 39 |
-
const messagesDiv = document.getElementById('messages');
|
| 40 |
-
const input = document.getElementById('userInput');
|
| 41 |
-
const btn = document.getElementById('sendBtn');
|
| 42 |
-
|
| 43 |
-
function appendMessage(role, text) {
|
| 44 |
-
const msgDiv = document.createElement('div');
|
| 45 |
-
msgDiv.className = `message ${role}`;
|
| 46 |
-
msgDiv.textContent = text;
|
| 47 |
-
messagesDiv.appendChild(msgDiv);
|
| 48 |
-
messagesDiv.scrollTop = messagesDiv.scrollHeight;
|
| 49 |
-
}
|
| 50 |
-
|
| 51 |
-
async function sendMessage() {
|
| 52 |
-
const text = input.value.trim();
|
| 53 |
-
if (!text) return;
|
| 54 |
-
|
| 55 |
-
// UI update
|
| 56 |
-
appendMessage('user', text);
|
| 57 |
-
input.value = '';
|
| 58 |
-
btn.disabled = true;
|
| 59 |
-
|
| 60 |
-
try {
|
| 61 |
-
// Отправляем на наш Python Backend
|
| 62 |
-
const response = await fetch('/api/chat', {
|
| 63 |
-
method: 'POST',
|
| 64 |
-
headers: { 'Content-Type': 'application/json' },
|
| 65 |
-
body: JSON.stringify({ user_email: userEmail, role: 'user', content: text })
|
| 66 |
-
});
|
| 67 |
-
const data = await response.json();
|
| 68 |
-
appendMessage('assistant', data.response);
|
| 69 |
-
} catch (error) {
|
| 70 |
-
console.error('Error:', error);
|
| 71 |
-
appendMessage('assistant', 'Ошибка соединения с сервером.');
|
| 72 |
-
} finally {
|
| 73 |
-
btn.disabled = false;
|
| 74 |
-
}
|
| 75 |
-
}
|
| 76 |
-
|
| 77 |
-
function handleEnter(e) {
|
| 78 |
-
if (e.key === 'Enter') sendMessage();
|
| 79 |
-
}
|
| 80 |
-
</script>
|
| 81 |
-
|
| 82 |
-
</body>
|
| 83 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|