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>AskOscar Herbal AI 🌿</title> | |
| <style> | |
| body { | |
| font-family: "Garamond", serif; | |
| background-image: url("c46cfe98-a47f-4596-a93b-ea93bb8806f3.jpg"); | |
| background-size: cover; | |
| background-position: center; | |
| color: #fff; | |
| text-align: center; | |
| height: 100vh; | |
| margin: 0; | |
| display: flex; | |
| flex-direction: column; | |
| justify-content: center; | |
| backdrop-filter: brightness(0.4); | |
| } | |
| h1 { | |
| font-size: 2.5em; | |
| margin-bottom: 10px; | |
| text-shadow: 2px 2px 5px #000; | |
| } | |
| p { | |
| margin-top: 0; | |
| font-size: 1.2em; | |
| text-shadow: 1px 1px 3px #000; | |
| } | |
| .container { | |
| background-color: rgba(0, 0, 0, 0.6); | |
| border-radius: 20px; | |
| padding: 30px; | |
| max-width: 650px; | |
| margin: 0 auto; | |
| box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5); | |
| display: flex; | |
| flex-direction: column; | |
| align-items: center; | |
| height: 80vh; | |
| } | |
| #chat-box { | |
| background-color: rgba(255, 255, 255, 0.1); | |
| border-radius: 10px; | |
| padding: 15px; | |
| width: 100%; | |
| height: 65%; | |
| overflow-y: auto; | |
| text-align: left; | |
| margin-bottom: 15px; | |
| box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5); | |
| } | |
| .message { | |
| margin-bottom: 15px; | |
| line-height: 1.4em; | |
| } | |
| .user { | |
| text-align: right; | |
| color: #aef7c7; | |
| } | |
| .bot { | |
| text-align: left; | |
| color: #fffbe6; | |
| } | |
| .input-container { | |
| width: 100%; | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| } | |
| input { | |
| width: 70%; | |
| padding: 12px; | |
| border: none; | |
| border-radius: 10px; | |
| font-size: 1em; | |
| margin-top: 10px; | |
| } | |
| button { | |
| background-color: #00b894; | |
| border: none; | |
| border-radius: 10px; | |
| padding: 12px 20px; | |
| font-size: 1em; | |
| color: white; | |
| cursor: pointer; | |
| margin-left: 10px; | |
| transition: background 0.3s ease; | |
| } | |
| button:hover { | |
| background-color: #019870; | |
| } | |
| .top-buttons { | |
| position: absolute; | |
| top: 15px; | |
| right: 15px; | |
| display: flex; | |
| gap: 10px; | |
| z-index: 1000; | |
| } | |
| .top-buttons button { | |
| background-color: #019870; | |
| border-radius: 8px; | |
| padding: 8px 14px; | |
| font-size: 0.9em; | |
| } | |
| footer { | |
| position: absolute; | |
| bottom: 10px; | |
| width: 100%; | |
| text-align: center; | |
| font-size: 0.9em; | |
| color: #ccc; | |
| } | |
| .modal { | |
| display: none; | |
| position: fixed; | |
| z-index: 999; | |
| left: 0; | |
| top: 0; | |
| width: 100%; | |
| height: 100%; | |
| overflow: auto; | |
| background-color: rgba(0, 0, 0, 0.8); | |
| } | |
| .modal-content { | |
| background-color: #222; | |
| margin: 15% auto; | |
| padding: 20px; | |
| border-radius: 10px; | |
| width: 80%; | |
| max-width: 500px; | |
| text-align: left; | |
| color: #eee; | |
| box-shadow: 0 0 15px rgba(0, 0, 0, 0.6); | |
| } | |
| .close { | |
| color: #aaa; | |
| float: right; | |
| font-size: 22px; | |
| cursor: pointer; | |
| } | |
| .close:hover { | |
| color: white; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="top-buttons"> | |
| <button id="aboutBtn">About</button> | |
| <button id="donateBtn">Donate</button> | |
| </div> | |
| <div class="container"> | |
| <h1>🌿 AskOscar Herbal AI 🌿</h1> | |
| <p>Ask me anything about medicinal plants, healing herbs, or natural remedies worldwide.</p> | |
| <div id="chat-box"></div> | |
| <div class="input-container"> | |
| <input id="userInput" placeholder="Ask about any medicinal plant..." /> | |
| <button id="askButton">Ask</button> | |
| </div> | |
| </div> | |
| <footer>Powered by Hugging Face • Herbal Wisdom by Oscar</footer> | |
| <!-- About Modal --> | |
| <div id="aboutModal" class="modal"> | |
| <div class="modal-content"> | |
| <span class="close" id="closeAbout">×</span> | |
| <h2>About</h2> | |
| <p> | |
| Oscar Teye, visionary founder of <strong>AskOscar.ai</strong>, connecting humanity with nature's healing power using intelligence and wisdom. | |
| </p> | |
| </div> | |
| </div> | |
| <!-- Donate Modal --> | |
| <div id="donateModal" class="modal"> | |
| <div class="modal-content"> | |
| <span class="close" id="closeDonate">×</span> | |
| <h2>Support AskOscar.ai</h2> | |
| <p> | |
| 🌿 Every seed of support helps this herbal AI grow stronger! | |
| You can contribute via Mobile Money: <strong>0530327720</strong> or share the website with friends 🌍 | |
| </p> | |
| </div> | |
| </div> | |
| <script> | |
| document.addEventListener("DOMContentLoaded", () => { | |
| // --- Corrected askOscarAI function --- | |
| async function askOscarAI(question) { | |
| try { | |
| const response = await fetch("/ask", { // ← call local server | |
| method: "POST", | |
| headers: { "Content-Type": "application/json" }, | |
| body: JSON.stringify({ question }) | |
| }); | |
| const data = await response.json(); | |
| return data.answer; | |
| } catch (err) { | |
| console.error(err); | |
| return "⚠️ Unable to connect to the herbal network."; | |
| } | |
| } | |
| const chatBox = document.getElementById("chat-box"); | |
| const input = document.getElementById("userInput"); | |
| const sendBtn = document.getElementById("askButton"); | |
| async function sendQuestion() { | |
| const question = input.value.trim(); | |
| if (!question) return; | |
| const userMsg = document.createElement("div"); | |
| userMsg.classList.add("message", "user"); | |
| userMsg.textContent = "🧍 " + question; | |
| chatBox.appendChild(userMsg); | |
| const botMsg = document.createElement("div"); | |
| botMsg.classList.add("message", "bot"); | |
| botMsg.textContent = "🌿 Thinking..."; | |
| chatBox.appendChild(botMsg); | |
| chatBox.scrollTop = chatBox.scrollHeight; | |
| input.value = ""; | |
| const answer = await askOscarAI(question); | |
| botMsg.textContent = "🪴 " + answer; | |
| chatBox.scrollTop = chatBox.scrollHeight; | |
| } | |
| sendBtn.addEventListener("click", sendQuestion); | |
| input.addEventListener("keypress", (e) => { if (e.key === "Enter") sendQuestion(); }); | |
| const aboutModal = document.getElementById("aboutModal"); | |
| const donateModal = document.getElementById("donateModal"); | |
| const aboutBtn = document.getElementById("aboutBtn"); | |
| const donateBtn = document.getElementById("donateBtn"); | |
| const closeAbout = document.getElementById("closeAbout"); | |
| const closeDonate = document.getElementById("closeDonate"); | |
| aboutBtn.onclick = () => (aboutModal.style.display = "block"); | |
| donateBtn.onclick = () => (donateModal.style.display = "block"); | |
| closeAbout.onclick = () => (aboutModal.style.display = "none"); | |
| closeDonate.onclick = () => (donateModal.style.display = "none"); | |
| window.onclick = (event) => { | |
| if (event.target === aboutModal) aboutModal.style.display = "none"; | |
| if (event.target === donateModal) donateModal.style.display = "none"; | |
| }; | |
| }); | |
| </script> | |
| </body> | |
| </html> | |