Spaces:
Sleeping
Sleeping
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Hinglish Semantic Bot</title> | |
| <style> | |
| body { font-family: sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #f0f2f5; } | |
| .container { background-color: white; padding: 2rem; border-radius: 10px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); text-align: center; max-width: 400px; width: 100%; } | |
| textarea { width: 100%; height: 100px; padding: 10px; margin-bottom: 15px; border: 1px solid #ccc; border-radius: 5px; resize: none; box-sizing: border-box; } | |
| button { background-color: #0084ff; color: white; border: none; padding: 10px 20px; border-radius: 5px; cursor: pointer; font-size: 16px; width: 100%; } | |
| button:hover { background-color: #006bce; } | |
| #result { margin-top: 20px; font-size: 48px; } | |
| .loading { font-size: 16px; color: #666; } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="container"> | |
| <h1>Hinglish Semantic Bot</h1> | |
| <p>Type a message in Hinglish to get an emoji reaction!</p> | |
| <textarea id="textInput" placeholder="E.g., bhai sach me rofl ho gaya..."></textarea> | |
| <button onclick="getEmoji()">Get Emoji Reaction</button> | |
| <div id="result"></div> | |
| </div> | |
| <script> | |
| async function getEmoji() { | |
| const text = document.getElementById('textInput').value.trim(); | |
| const resultDiv = document.getElementById('result'); | |
| if (!text) { | |
| resultDiv.innerHTML = '<span style="font-size: 16px; color: red;">Please enter some text.</span>'; | |
| return; | |
| } | |
| resultDiv.innerHTML = '<span class="loading">Thinking...</span>'; | |
| try { | |
| const response = await fetch('/api/predict', { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify({ text: text }) | |
| }); | |
| if (response.ok) { | |
| const data = await response.json(); | |
| resultDiv.innerText = data.emoji; | |
| } else { | |
| resultDiv.innerHTML = '<span style="font-size: 16px; color: red;">Error processing request.</span>'; | |
| } | |
| } catch (error) { | |
| resultDiv.innerHTML = '<span style="font-size: 16px; color: red;">Failed to connect to server.</span>'; | |
| } | |
| } | |
| </script> | |
| </body> | |
| </html> | |