File tree Expand file tree Collapse file tree 1 file changed +20
-10
lines changed Expand file tree Collapse file tree 1 file changed +20
-10
lines changed Original file line number Diff line number Diff line change 1
1
// Create Web Server
2
2
// Create a web server that listens on port 3000 and serves the comments.html file
3
3
// when someone visits http://localhost:3000/comments.
4
- // Use the fs module to read the comments.html file and serve it back to the user.
5
- // Use the http module to create the server.
6
4
7
- const http = require ( 'http' ) ;
8
- const fs = require ( 'fs' ) ;
9
- const path = require ( 'path' ) ;
5
+ // This means you will need to create a comments.html file in your project directory.
6
+ // The comments.html file should have an h1 tag that says "Comments" and a ul tag
7
+ // with at least 5 li tags with comments in them.
10
8
11
- const server = http . createServer ( ( req , res ) => {
12
- console . log ( `Request made to ${ req . url } ` ) ;
9
+ // When you visit http://localhost:3000/comments in your browser, you should see the
10
+ // comments page.
13
11
14
- if ( req . url === '/comments' ) {
15
- fs . readFile ( path . join ( __dirname ) ) ; }
16
- } ) ;
12
+ // Make sure you are using the fs module to read the contents of the comments.html
13
+ // file.
14
+
15
+ // You can use the following code to read the contents of the comments.html file:
16
+
17
+ // fs.readFile('./comments.html', 'utf8', (err, data) => {
18
+ // if (err) {
19
+ // throw err;
20
+ // }
21
+ // console.log(data);
22
+ // });
23
+ // You can use the following code to serve the contents of the comments.html file:
24
+
25
+ // http.createServer((req, res) => {
26
+ // fs.readFile('./comments.html', 'utf8'
You can’t perform that action at this time.
0 commit comments