LLM-fastAPI / index.html
Songyou's picture
change
1b10c0c
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FastAPI Example</title>
</head>
<body>
<h1>FastAPI Input Example</h1>
<input type="text" id="user_input" placeholder="Enter something...">
<button onclick="submitInput()">Submit</button>
<p id="response"></p>
<script>
function submitInput() {
const input = document.getElementById("user_input").value;
fetch("/submit", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ user_input: input })
})
.then(response => response.json())
.then(data => {
document.getElementById("response").textContent = "Response: " + data.message;
})
.catch(error => console.error("Error:", error));
}
</script>
</body>
</html>