Update static/index.html
Browse files- static/index.html +30 -34
static/index.html
CHANGED
|
@@ -1,36 +1,32 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
-
|
| 4 |
-
<meta charset="UTF-8"
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0"
|
| 6 |
-
<title>
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
<
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
</section>
|
| 34 |
-
</main>
|
| 35 |
-
</body>
|
| 36 |
-
</html>
|
|
|
|
| 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>
|
|
|
|
|
|
|
|
|
|
|
|