-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnodesamp.js
32 lines (27 loc) · 1.12 KB
/
nodesamp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var express = require('express');
var app = express();
var portNum = 8081;
// Display Ready Message if root path was specified
app.get('/', displayReady);
app.get('/hello/:name', displayHello);
app.listen(portNum, displayStarted);
function displayReady(req, res) {
res.write("===================================================\n");
res.write("= Node.js sample application on Docker container =\n");
res.write("===================================================\n");
res.write("= ***** ****** *** **** ** ** =\n");
res.write("= ** *** ** ** ** ** ** ** ** =\n");
res.write("= ***** ****** ******* ** ** **** =\n");
res.write("= ** ** ** ** ** ** ** ** =\n");
res.write("= ** ** ****** ** ** **** ** =\n");
res.write("===================================================\n");
res.end();
}
function displayHello(req, res) {
var name = req.params.name;
res.write("Hello " + name + "! How are you?");
res.end();
}
function displayStarted() {
console.log('Demo application listening on port ' + portNum);
}