main.js
package.json
server.log
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
constexpress = require('express');
constapp = express();
constPORT = process.env.PORT || 3000;
// 中间件设置
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
// 路由定义
app.get('/', (req, res) => {
res.send('Hello World!');
});
app.get('/api/users', (req, res) => {
res.json({ users: [] });
});
// 启动服务器
app.listen(PORT, () => {
console.log(`服务器运行在端口 ${PORT}`);
});
module.exports = app;
调试控制台
$技术交流
>暂无消息,等待连接...
$
○ 未连接👥 0 人在线
就绪 main.js
Ln 1, Col 1UTF-8空格: 2