Skip to content

Commit 41e7628

Browse files
committed
Added basic app.js and html files
1 parent 1f4f694 commit 41e7628

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

another-page.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
5+
<title>Anbothger Page</title>
6+
7+
</head>
8+
<body>
9+
10+
<h1>Another Page</h1>
11+
12+
<p>This is a second page in the basic Node.js website.</p>
13+
14+
<a href="/index.html">Back to the Home Page</a>
15+
16+
</body>
17+
</html>

app.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
var http = require('http');
2+
var url = require('url');
3+
var fs = require('fs');
4+
5+
http.createServer(function (req, res) {
6+
7+
var q = url.parse(req.url, true);
8+
9+
var filename = "." + q.pathname;
10+
11+
fs.readFile(filename, function(err, data) {
12+
13+
if (err) {
14+
15+
res.writeHead(404, {'Content-Type': 'text/html'});
16+
return res.end("404 Not Found");
17+
18+
}
19+
20+
res.writeHead(200, {'Content-Type': 'text/html'});
21+
res.write(data);
22+
return res.end();
23+
24+
});
25+
26+
}).listen(8080);

index.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
5+
<title>My Node.js Website</title>
6+
7+
</head>
8+
<body>
9+
10+
<h1>My Node.js Website</h1>
11+
12+
<p>This is a basic website using Node.js and the build in http and fs modules.</p>
13+
14+
<a href="/another-page.html">Another Page</a>
15+
16+
</body>
17+
</html>

0 commit comments

Comments
 (0)