forked from t-crow-142/wdcc-server-side-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexercise-02.js
22 lines (19 loc) · 923 Bytes
/
exercise-02.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// The express package contains Express, and its own required dependencies. It needs to be
// installed using npm.
const express = require("express");
const app = express();
const port = 3000;
// Setup static routing. Any file located in the "public" folder
// will be able to be accessed by clients directly.
const path = require("path");
app.use(express.static(path.join(__dirname, "public")));
// When a GET request is made to "/" (i.e. the root path), send "Hello World!" back to the client.
app.get("/", function (req, res) {
res.send("Hello World!");
});
// Start the server running. Once the server is running, the given function will be called, which will
// log a simple message to the server console. Any console.log() statements in your node.js code
// can be seen in the terminal window used to run the server.
app.listen(port, function () {
console.log(`Example app listening on port ${port}!`);
});