Skip to content

Commit df2d217

Browse files
authored
Update README.md
1 parent 2242432 commit df2d217

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ This tutorial will walk you through the creation of a very basic website using o
1313
5. Create a new file called app.js.
1414
6. In app.js import the required modules:
1515

16-
```
16+
```js
1717
var http = require('http');
1818
var url = require('url');
1919
var fs = require('fs');
2020
```
2121

2222
7. Create an http server:
2323

24-
```
24+
```js
2525
http.createServer(function (req, res) {
2626
}).listen(8080);
2727
```
@@ -30,14 +30,14 @@ This will start a web server. The server is available to test by opening a brows
3030

3131
8. Inside the `createServer` function add code to fetch the current URL:
3232

33-
```
33+
```js
3434
var q = url.parse(req.url, true);
3535
var filename = "." + q.pathname;
3636
```
3737

3838
9. Inside the `createServer` function, after the the previous lines of code, add code to load the appropriate HTML file based on the URL. For example the URL `http://localhost:8080/index.html` will should the index.html file.
3939

40-
```
40+
```js
4141
fs.readFile(filename, function(err, data) {
4242
res.writeHead(200, {'Content-Type': 'text/html'});
4343
res.write(data);
@@ -47,7 +47,7 @@ fs.readFile(filename, function(err, data) {
4747

4848
10. Inside the `readFile` function, add code that will display an error message in case the requested URL does not match an exsting file:
4949

50-
```
50+
```js
5151
if (err) {
5252
res.writeHead(404, {'Content-Type': 'text/html'});
5353
return res.end("404 Not Found");
@@ -60,7 +60,7 @@ if (err) {
6060

6161
Your final code in app.js should look like this:
6262

63-
```nodejs
63+
```js
6464
var http = require('http');
6565
var url = require('url');
6666
var fs = require('fs');

0 commit comments

Comments
 (0)