forked from sushmaratakonda/python-backend-testing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
157 lines (137 loc) · 3.48 KB
/
Copy pathindex.html
File metadata and controls
157 lines (137 loc) · 3.48 KB
1
2
3
4
5
6
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!DOCTYPE html>
<html>
<head>
<title>User API Frontend</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #eef2f7;
margin: 40px;
color: #333;
}
.header {
display: flex;
align-items: center;
gap: 15px;
}
.header img {
height: 50px;
}
h2 {
color: #2c3e50;
text-shadow: 1px 1px 2px #ccc;
margin: 0;
}
h3 {
color: #34495e;
margin-top: 50px;
}
table {
width: 70%;
border-collapse: collapse;
margin-top: 20px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
background-color: #ffffff;
border-radius: 6px;
overflow: hidden;
}
th, td {
padding: 14px 18px;
text-align: left;
}
th {
background-color: #2980b9;
color: white;
font-size: 16px;
letter-spacing: 1px;
}
tr:nth-child(even) {
background-color: #f4f6f8;
}
tr:hover {
background-color: #e1ecf4;
transition: 0.2s ease-in-out;
}
input[type="text"], input[type="email"] {
padding: 10px;
width: 200px;
margin-right: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 15px;
}
button {
padding: 10px 18px;
background-color: #27ae60;
border: none;
color: white;
font-size: 15px;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background-color: #219150;
}
#formMsg {
margin-top: 12px;
font-weight: bold;
color: #d63031;
}
</style>
</head>
<body>
<div class="header">
<img src="veera" alt=" Logo">
<h2>Welcome to multicloud devops</h2>
</div>
<table id="userTable">
<tr><th>ID</th><th>Name</th><th>Email</th></tr>
</table>
<h3>Add New User</h3>
<form id="userForm">
<input type="text" id="name" placeholder="Enter Name" required>
<input type="email" id="email" placeholder="Enter Email" required>
<button type="submit">Add User</button>
</form>
<p id="formMsg"></p>
<script>
const backendIP = "http://54.196.202.58:5000"; // Replace with your backend IP if needed
function loadUsers() {
fetch(`${backendIP}/users`)
.then(response => response.json())
.then(users => {
const table = document.getElementById("userTable");
users.forEach(user => {
const row = table.insertRow();
row.insertCell(0).innerText = user.id;
row.insertCell(1).innerText = user.name;
row.insertCell(2).innerText = user.email;
});
})
.catch(err => {
console.error("Failed to load users:", err);
});
}
document.getElementById("userForm").addEventListener("submit", function(e) {
e.preventDefault();
const name = document.getElementById("name").value;
const email = document.getElementById("email").value;
fetch(`${backendIP}/users/add`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ name, email })
})
.then(res => res.json())
.then(result => {
document.getElementById("formMsg").textContent = result.message || result.error;
location.reload();
})
.catch(err => {
document.getElementById("formMsg").textContent = "Error adding user.";
console.error("Add error:", err);
});
});
loadUsers();
</script>
</body>
</html>