1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Torrent Monitor</title>
- <script src="{{ url_for('static', filename='js/jquery-3.7.1.min.js') }}"></script>
- <script src="{{ url_for('static', filename='js/socket.io.js') }}"></script>
- </head>
- <body>
- <h1>Torrent Monitor</h1>
- <table id="torrentsTable" border="1">
- <thead>
- <tr>
- <th>Name</th>
- <th>Download Speed</th>
- <th>Upload Speed</th>
- <th>Status</th>
- </tr>
- </thead>
- <tbody>
- <!-- 表格内容将通过SocketIO动态更新 -->
- </tbody>
- </table>
- <script>
- $(document).ready(function(){
- var socket = io.connect('http://' + document.domain + ':' + location.port);
- socket.on('torrents_status_update', function(data) {
- console.log("Received torrents status update:", data); // 打印接收到的数据到控制台
- var tbody = $('#torrentsTable tbody');
- tbody.empty(); // 清空表格内容
- console.log(data)
- // 确保data对象中包含torrents_status_update属性,并且它是一个数组
- if (data.torrents_status_update && Array.isArray(data.torrents_status_update)) {
- data.torrents_status_update.forEach(function(torrent) {
- var row = `<tr>
- <td>${torrent.name}</td>
- <td>${torrent.download_speed}</td>
- <td>${torrent.upload_speed}</td>
- <td>${torrent.status}</td>
- </tr>`;
- tbody.append(row);
- });
- } else {
- console.error("Error: Data does not contain a torrents_status_update array.");
- }
- });
- });
- </script>
- </body>
- </html>
|