-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathattendance.html
More file actions
70 lines (66 loc) · 2.42 KB
/
Copy pathattendance.html
File metadata and controls
70 lines (66 loc) · 2.42 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
<!DOCTYPE html>
<html>
<head>
<title>Attendance</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f0f0;
}
form {
background: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
input, button {
margin-top: 10px;
padding: 10px;
width: 100%;
}
</style>
</head>
<body>
<h1>Get Password</h1>
<form id="generate-password-form">
<label for="studentNumber">Student Number:</label>
<input type="text" id="studentNumber" name="studentNumber" required>
<button type="submit">Get Password</button>
</form>
<p id="response"></p>
<script>
document.getElementById('generate-password-form').addEventListener('submit', async function(event) {
event.preventDefault(); // Prevent the form from submitting normally
const studentNumber = document.getElementById('studentNumber').value;
const responseElement = document.getElementById('response');
try {
// Fetch request to the Flask server
const response = await fetch(`http://127.0.0.1:5000/generate-password?studentNumber=${encodeURIComponent(studentNumber)}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
});
// Check if the response was successful
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
// Parse the JSON response
const data = await response.json();
if (data.success) {
responseElement.innerText = `Password: ${data.password}`;
} else {
responseElement.innerText = `Error: ${data.message}`;ssss
}
} catch (error) {
// Handle errors (e.g., network errors, server errors)
responseElement.innerText = `An error occurred: ${error.message}`;
}
});
</script>
</body>
</html>