-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatic.js
More file actions
47 lines (46 loc) · 1.4 KB
/
static.js
File metadata and controls
47 lines (46 loc) · 1.4 KB
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
42
43
44
45
46
47
var http = require('http');
var fs = require('fs');
// var path = require('path');
module.exports = function(request, response) {
console.log(request.url);
if(request.url === '/')
{
// console.log('over here');
fs.readFile('views/index.html', 'utf8', function (errors, contents){
response.writeHead(200, {'Content-Type': 'text/html'});
response.write(contents);
response.end();
});
}
else if (request.url === "/stylesheet.css")
{
fs.readFile('./stylesheets/stylesheet.css', 'utf8', function (errors, contents){
response.writeHead(200, {'Content-type': 'text/css'});
response.write(contents);
response.end();
});
}
// Cat page //
else if(request.url === '/cats')
{
fs.readFile('views/cats.html', 'utf8', function (errors, contents){
response.writeHead(200, {'Content-Type': 'text/html'});
response.write(contents);
response.end();
});
}
else if (request.url === "/Snoopy")
{
fs.readFile('./images/Snoopy.png', function (errors, contents){
response.writeHead(200, {'Content-type': 'image/*'});
response.write(contents);
response.end();
});
}
// End Cats //
// request didn't match anything:
else
{
response.end('File not found!!!');
}
};