| <!DOCTYPE html> |
| <html> |
| <head> |
| <meta charset="utf-8"> |
| <title>Newton — Локальный ИИ</title> |
| <style> |
| body { font-family: Arial, sans-serif; max-width: 800px; margin: 40px auto; padding: 0 20px; } |
| h1 { color: #2c3e50; } |
| textarea { width: 100%; height: 80px; padding: 10px; margin: 10px 0; box-sizing: border-box; } |
| button { padding: 12px 24px; background: #3498db; color: white; border: none; cursor: pointer; font-size: 16px; } |
| button:hover { background: #2980b9; } |
| #answer { margin-top: 20px; padding: 15px; background: #f8f9fa; border-left: 4px solid #3498db; } |
| .status { color: #e74c3c; } |
| </style> |
| </head> |
| <body> |
| <h1>Newton search</h1> |
| <p>Твой личный ИИ. Работает только если запущен <code>server.py</code>.</p> |
| |
| <textarea id="query" placeholder="Например: поиск: что такое Ubuntu?"></textarea> |
| <br> |
| <button onclick="ask()">Получить ответ</button> |
| |
| <div id="answer"></div> |
|
|
| <script> |
| async function ask() { |
| const query = document.getElementById("query").value; |
| const answerDiv = document.getElementById("answer"); |
| answerDiv.innerHTML = "Думаю..."; |
| |
| try { |
| const res = await fetch("http://localhost:8000/ask", { |
| method: "POST", |
| headers: { "Content-Type": "application/json" }, |
| body: JSON.stringify({ query: query }) |
| }); |
| const data = await res.json(); |
| answerDiv.innerHTML = `<strong>💡 Ответ:</strong> ${data.answer}`; |
| } catch (e) { |
| answerDiv.innerHTML = `<span class="status">❌ Ошибка: убедитесь, что запущен Newton Search на localhost:8000</span>`; |
| } |
| } |
| </script> |
| </body> |
| </html> |
|
|