01.
02.
var
express = require(
'express'
);
03.
var
app = express();
04.
05.
app.set(
'view engine'
,
'ejs'
);
06.
app.use(express.static(__dirname));
07.
08.
09.
var
mongo = require(
"./mongo.js"
);
10.
mongo.connect();
11.
12.
app.get(
'/'
,
function
(req, res) {
13.
14.
mongo.getdb().collection(
"info"
).find({}).toArray(
function
(err, result) {
15.
if
(err)
throw
err;
16.
console.log(result);
17.
});
18.
19.
res.render(
'index.ejs'
);
20.
21.
});
22.
23.
24.
var
server = app.listen(1000,
function
() {
25.
var
host = server.address().address;
26.
var
port = server.address().port;
27.
console.log(
"Example app listening at http://%s:%s"
, host, port);
28.
});