This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Markdown 6 hrs ██████████░░░░░░░░░░░ 48.0% | |
JavaScript 1 hr 39 mins ██▊░░░░░░░░░░░░░░░░░░ 13.2% | |
JSON 1 hr 10 mins █▉░░░░░░░░░░░░░░░░░░░ 9.3% | |
Bash 58 mins █▋░░░░░░░░░░░░░░░░░░░ 7.8% | |
Groovy 50 mins █▍░░░░░░░░░░░░░░░░░░░ 6.7% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); // 导入 Express 模块 | |
const app = express(); // 创建 express() 实例 | |
// 路由定义 | |
// 监听根路径`/` | |
app.get('/', (req, res) => { | |
res.send('Hello World!'); | |
}); | |
// 在3000端口启动服务器并打印日志 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 调用 HTTP 模块 | |
const http = require("http"); | |
// 创建 HTTP 服务器并监听 8000 端口的所有请求 | |
http.createServer((request, response) => { | |
// 用 HTTP 状态码和内容类型来设定 HTTP 响应头 | |
response.writeHead(200, {'Content-Type': 'text/plain'}); | |
// 发送响应体 "Hello World" |