34 lines
765 B
JavaScript
34 lines
765 B
JavaScript
// 简单的服务器测试脚本
|
|
import express from 'express';
|
|
|
|
const app = express();
|
|
const PORT = 3201;
|
|
const HOST = '0.0.0.0';
|
|
|
|
// 基本路由
|
|
app.get('/', (req, res) => {
|
|
res.send('服务器测试成功!');
|
|
});
|
|
|
|
app.get('/health', (req, res) => {
|
|
res.json({
|
|
status: 'ok',
|
|
timestamp: new Date().toISOString(),
|
|
version: '1.0.0'
|
|
});
|
|
});
|
|
|
|
// 启动服务器
|
|
const server = app.listen(PORT, HOST, () => {
|
|
console.log(`✅ 测试服务器启动成功!`);
|
|
console.log(`🚀 访问地址: http://${HOST}:${PORT}`);
|
|
});
|
|
|
|
// 处理退出信号
|
|
process.on('SIGINT', () => {
|
|
console.log('🛑 收到退出信号,关闭测试服务器...');
|
|
server.close(() => {
|
|
console.log('✅ 测试服务器已关闭');
|
|
process.exit(0);
|
|
});
|
|
}); |