-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js.example
41 lines (21 loc) · 1.26 KB
/
server.js.example
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
33
34
35
36
37
38
39
40
41
// Require http module
// Require fs module
// Require minimist module (make sure you install this one via npm).
// Use minimist to process one argument `--port=` on the command line after `node server.js`.
// Define a const `port` using the argument from the command line.
// Make this const default to port 3000 if there is no argument given for `--port`.
// Use the fs module to create an arrow function using `fs.readFile`.
// Use the documentation for the Node.js `fs` module.
// The function must read a file located at `./public/index.html` and do some stuff with it.
// The stuff that should be inside this function is all below.
// If there is an error, put it on the console error and return.
// Do not be nice about exiting.
// Define a const `server` as an arrow function using http.createServer.
// Use the documentation for the node.js http module.
// The function should have three responses:
// 1. status code 200,
// 2. set a header with content type `text/html`, and
// 3. end with the data that you are reading in from ./public/index.html.
// Start the `server` const listening on the port defined by argument in your `port` const.
// Put the exact message `Server listening on port ${port}` on the console log.
// That's it! You're all done!