🧩 基本结构

使用 Node.js 创建基础服务器的步骤如下:

  1. 初始化项目

    npm init -y
    
  2. 安装依赖

    npm install express
    
  3. 创建服务器文件 server.js

    const express = require('express');
    const app = express();
    const port = 3000;
    
    app.get('/案例三', (req, res) => {
      res.send('欢迎访问案例三!');
    });
    
    app.listen(port, () => {
      console.log(`服务器运行在 http://localhost:${port}`);
    });
    

📌 扩展阅读

HTTP_Server
Node_js