Skip to content

Commit caaa088

Browse files
author
Ryan Kotzen
committed
express!
1 parent 434efd8 commit caaa088

4 files changed

Lines changed: 301 additions & 79 deletions

File tree

.idea/workspace.xml

Lines changed: 64 additions & 79 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node/express/index.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
const express = require('express');
3+
const app = express();
4+
const host = 'localhost';
5+
const port = 8080;
6+
app.get("/", [
7+
logIncomingRequest,
8+
sendHelloWorld
9+
]);
10+
11+
function logIncomingRequest(req, res, next) {
12+
console.info("[%s] Incoming request :", new Date().toISOString(), req.originalUrl);
13+
next();
14+
}
15+
function sendHelloWorld(req, res) {
16+
res.send("Hello World!");
17+
}
18+
19+
app.listen(port, function (err) {
20+
if (err) {
21+
throw err;
22+
}
23+
console.log("Server listening at http://%s:%s", host, port)
24+
});

0 commit comments

Comments
 (0)