Spaces:
Sleeping
Sleeping
Create index.html
Browse files- index.html +32 -0
index.html
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>FastAPI Example</title>
|
| 7 |
+
</head>
|
| 8 |
+
<body>
|
| 9 |
+
<h1>FastAPI Input Example</h1>
|
| 10 |
+
<input type="text" id="user_input" placeholder="Enter something...">
|
| 11 |
+
<button onclick="submitInput()">Submit</button>
|
| 12 |
+
<p id="response"></p>
|
| 13 |
+
|
| 14 |
+
<script>
|
| 15 |
+
function submitInput() {
|
| 16 |
+
const input = document.getElementById("user_input").value;
|
| 17 |
+
fetch("http://localhost:8000/submit", {
|
| 18 |
+
method: "POST",
|
| 19 |
+
headers: {
|
| 20 |
+
"Content-Type": "application/json"
|
| 21 |
+
},
|
| 22 |
+
body: JSON.stringify({ user_input: input })
|
| 23 |
+
})
|
| 24 |
+
.then(response => response.json())
|
| 25 |
+
.then(data => {
|
| 26 |
+
document.getElementById("response").textContent = "Response: " + data.message;
|
| 27 |
+
})
|
| 28 |
+
.catch(error => console.error("Error:", error));
|
| 29 |
+
}
|
| 30 |
+
</script>
|
| 31 |
+
</body>
|
| 32 |
+
</html>
|