Skip to content

Instantly share code, notes, and snippets.

@xiezipei
Created July 8, 2019 07:21
Show Gist options
  • Save xiezipei/c103db7090d09c2849122b631ee88bc9 to your computer and use it in GitHub Desktop.
Save xiezipei/c103db7090d09c2849122b631ee88bc9 to your computer and use it in GitHub Desktop.
Express 的 Hello World 的示例
const express = require('express'); // 导入 Express 模块
const app = express(); // 创建 express() 实例
// 路由定义
// 监听根路径`/`
app.get('/', (req, res) => {
res.send('Hello World!');
});
// 在3000端口启动服务器并打印日志
app.listen(3000, () => {
console.log('示例应用正在监听 3000 端口!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment