Loading [Contrib]/a11y/accessibility-menu.js

Express.js: Hello, World!

1. 安裝 Node.js

2. 安裝 Express.js
$npm install express --save
3. 建立 Express-HelloWorld.js
var express = require('express');
var app = express();
app.route('/Node').get(function(req,res)
{
res.send("Express route on Node");
});
app.route('/Angular').get(function(req,res)
{
res.send("Express route on Angular");
});
app.get('/',(function(req,res){
res.send('Hello, World! (via Express)');
}));
var server=app.listen(3000,function() {});

4. 執行 Express-HelloWorld.js
$node Express-HelloWorld.js
5. 觀查執行結果:


參考資料


Expressjs.com: Hello world example

Node.js Express Tutorial