<html> | |
<head> | |
<title>AI App Demo</title> | |
</head> | |
<body> | |
<h1>AI App Demo</h1> | |
<input type="text" id="userInput" placeholder="Enter your message"> | |
<button onclick="sendMessage()">Send</button> | |
<div id="response"></div> | |
<script> | |
function sendMessage() { | |
const userInput = document.getElementById('userInput').value; | |
fetch('/api/generate', { | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json' | |
}, | |
body: JSON.stringify({ message: userInput }) | |
}) | |
.then(response => response.json()) | |
.then(data => { | |
document.getElementById('response').innerHTML = data.response; | |
}); | |
} | |
</script> | |
</body> | |
</html> |