Spaces:
Configuration error
Configuration error
Create index.html
Browse files- index.html +64 -0
index.html
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>Data Submission</title>
|
| 7 |
+
<style>
|
| 8 |
+
body {
|
| 9 |
+
font-family: Arial, sans-serif;
|
| 10 |
+
margin: 20px;
|
| 11 |
+
}
|
| 12 |
+
.container {
|
| 13 |
+
max-width: 600px;
|
| 14 |
+
margin: auto;
|
| 15 |
+
}
|
| 16 |
+
form {
|
| 17 |
+
display: flex;
|
| 18 |
+
flex-direction: column;
|
| 19 |
+
}
|
| 20 |
+
label, input, button {
|
| 21 |
+
margin-bottom: 10px;
|
| 22 |
+
}
|
| 23 |
+
</style>
|
| 24 |
+
</head>
|
| 25 |
+
<body>
|
| 26 |
+
<div class="container">
|
| 27 |
+
<h1>Submit Data</h1>
|
| 28 |
+
<form id="dataForm">
|
| 29 |
+
<label for="userId">User ID:</label>
|
| 30 |
+
<input type="text" id="userId" name="user_id" required>
|
| 31 |
+
|
| 32 |
+
<label for="title">Title:</label>
|
| 33 |
+
<input type="text" id="title" name="title" required>
|
| 34 |
+
|
| 35 |
+
<button type="submit">Submit</button>
|
| 36 |
+
</form>
|
| 37 |
+
<p id="responseMessage"></p>
|
| 38 |
+
</div>
|
| 39 |
+
<script>
|
| 40 |
+
document.getElementById('dataForm').addEventListener('submit', async (e) => {
|
| 41 |
+
e.preventDefault();
|
| 42 |
+
|
| 43 |
+
const userId = document.getElementById('userId').value;
|
| 44 |
+
const title = document.getElementById('title').value;
|
| 45 |
+
const apiUrl = 'https://{api-id}.execute-api.{region}.amazonaws.com/{stage}/users'; // API Gateway URL'nizi buraya koyun
|
| 46 |
+
|
| 47 |
+
try {
|
| 48 |
+
const response = await fetch(apiUrl, {
|
| 49 |
+
method: 'POST',
|
| 50 |
+
headers: {
|
| 51 |
+
'Content-Type': 'application/json'
|
| 52 |
+
},
|
| 53 |
+
body: JSON.stringify({ user_id: userId, title: title })
|
| 54 |
+
});
|
| 55 |
+
|
| 56 |
+
const result = await response.json();
|
| 57 |
+
document.getElementById('responseMessage').textContent = `Response: ${JSON.stringify(result)}`;
|
| 58 |
+
} catch (error) {
|
| 59 |
+
document.getElementById('responseMessage').textContent = `Error: ${error}`;
|
| 60 |
+
}
|
| 61 |
+
});
|
| 62 |
+
</script>
|
| 63 |
+
</body>
|
| 64 |
+
</html>
|