parent
16f89ac361
commit
048a9d6636
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,20 @@
|
||||
from cryptography.fernet import Fernet
|
||||
import os
|
||||
|
||||
# 生成一个新的Fernet密钥
|
||||
key = Fernet.generate_key()
|
||||
|
||||
# 指定密钥文件的路径
|
||||
key_path = 'secret.key'
|
||||
|
||||
# 将密钥保存到文件中
|
||||
with open(key_path, 'wb') as key_file:
|
||||
key_file.write(key)
|
||||
|
||||
# 打印密钥以便查看
|
||||
# print(f"Generated key: {key.decode()}")
|
||||
|
||||
# 确保密钥文件的权限设置为只读
|
||||
os.chmod(key_path, 0o400)
|
||||
|
||||
print(f"Key has been saved to {key_path}")
|
@ -0,0 +1 @@
|
||||
xO0rhaZ7_TEiOBm2ZH2b6L9VIiECc_aO8FeY5HGt2nY=
|
@ -0,0 +1,29 @@
|
||||
// server.js
|
||||
const express = require('express');
|
||||
const http = require('http');
|
||||
const socketIo = require('socket.io');
|
||||
|
||||
const app = express();
|
||||
const server = http.createServer(app);
|
||||
const io = socketIo(server);
|
||||
|
||||
let clients = {};
|
||||
|
||||
io.on('connection', (socket) => {
|
||||
console.log('A client connected:', socket.id);
|
||||
clients[socket.id] = { status: 'connected' };
|
||||
|
||||
socket.on('disconnect', () => {
|
||||
console.log('A client disconnected:', socket.id);
|
||||
clients[socket.id] = { status: 'disconnected' };
|
||||
});
|
||||
|
||||
// 定时发送客户端状态
|
||||
setInterval(() => {
|
||||
io.emit('clients_status', clients);
|
||||
}, 5000);
|
||||
});
|
||||
|
||||
server.listen(3000, () => {
|
||||
console.log('Server listening on port 3000');
|
||||
});
|
@ -0,0 +1,39 @@
|
||||
<!-- templates/network.html -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Network Connection Status</title>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.min.js"></script>
|
||||
<style>
|
||||
body { font-family: Arial, sans-serif; }
|
||||
#network { padding: 20px; }
|
||||
.client {
|
||||
color: white;
|
||||
padding: 10px;
|
||||
margin: 5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.connected { background-color: green; }
|
||||
.disconnected { background-color: red; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Client Connection Status</h1>
|
||||
<div id="network"></div>
|
||||
<script>
|
||||
const socket = io('http://localhost:3000');
|
||||
const networkElement = document.getElementById('network');
|
||||
|
||||
socket.on('clients_status', (clients) => {
|
||||
networkElement.innerHTML = '';
|
||||
for (const [id, info] of Object.entries(clients)) {
|
||||
const clientElement = document.createElement('div');
|
||||
clientElement.className = 'client ' + info.status;
|
||||
clientElement.textContent = `Client ID: ${id} - Status: ${info.status}`;
|
||||
networkElement.appendChild(clientElement);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>网络信息系统注册</title>
|
||||
<link rel="stylesheet" href="/static/login.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="login">
|
||||
<form action="/register" method="post">
|
||||
<h2>网络信息系统注册</h2>
|
||||
<div class="login_box">
|
||||
<input type="text" name="captcha" id="captcha" required />
|
||||
<label for="captcha">注册码</label>
|
||||
</div>
|
||||
<div class="login_box">
|
||||
<input type="text" name="username" id="username" required />
|
||||
<label for="username">用户名</label>
|
||||
</div>
|
||||
<div class="login_box">
|
||||
<input type="password" name="password" id="password" required />
|
||||
<label for="password">密码</label>
|
||||
</div>
|
||||
<div class="login_box">
|
||||
<input type="password" name="password_confirm" id="password_confirm" required />
|
||||
<label for="password_confirm">确认密码</label>
|
||||
</div>
|
||||
<input type="submit" value="注册" class="register-button">
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,18 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Send Message</title>
|
||||
<title>发送消息</title>
|
||||
<link rel="stylesheet" href="/static/login.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>Send Message</h1>
|
||||
<div class="login">
|
||||
<h2>发送消息</h2>
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<label for="message">Message:</label>
|
||||
<h3>消息内容</h3>
|
||||
<textarea id="message" name="message" rows="4" cols="50" required></textarea><br><br>
|
||||
<label for="photo">Upload Photo:</label>
|
||||
<h3>选择图片</h3>
|
||||
<input type="file" id="photo" name="photo"><br><br>
|
||||
<button type="submit">Send Message</button>
|
||||
<button type="submit" class="register-button">发送</button>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in new issue