match_face/templates/index.html

85 lines
2.5 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>Face Match Logs</title>
<script src="https://cdn.socket.io/4.0.0/socket.io.min.js"></script>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
text-align: center;
}
h1 {
color: #333;
padding: 20px;
margin: 0;
background-color: #007bff;
color: white;
}
table {
width: 80%;
margin: 20px auto;
border-collapse: collapse;
}
th, td {
padding: 12px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background-color: #007bff;
color: white;
}
tr:hover {
background-color: #f5f5f5;
}
img {
max-width: 100px; /* 照片最大宽度 */
height: auto;
border-radius: 5px;
}
</style>
<script>
document.addEventListener("DOMContentLoaded", function() {
// 连接到 Socket.IO 服务器
var socket = io.connect('http://' + document.domain + ':' + location.port);
// 监听 'update' 事件
socket.on('update', function(data) {
var tableBody = document.getElementById('log-table-body');
tableBody.innerHTML = ''; // 清空现有的表格行
// 遍历日志数据并更新表格
data.logs.forEach(function(log) {
var row = document.createElement('tr');
row.innerHTML = '<td>' + log[0] + '</td>' +
'<td>' + log[1] + '</td>' +
'<td>' + log[3] + '</td>' +
'<td><img src="' + '../static/' + log[2] + '" alt="Photo of ' + log[0] + '"></td>';
// log[4] 假设是照片的路径
tableBody.appendChild(row);
});
});
});
</script>
</head>
<body>
<h1>进入记录</h1>
<table border="0">
<thead>
<tr>
<th>姓名</th>
<th>身份</th>
<th>进入时间</th>
<th>照片</th> <!-- 新增照片列 -->
</tr>
</thead>
<tbody id="log-table-body">
<!-- 日志行将在 JavaScript 中插入 -->
</tbody>
</table>
</body>
</html>