-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhandler.js
More file actions
48 lines (38 loc) · 994 Bytes
/
handler.js
File metadata and controls
48 lines (38 loc) · 994 Bytes
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
48
var handler = module.exports = {};
var fs = require('fs');
var index = fs.readFileSync(__dirname + '/public/html/index.html');
var mainJs = fs.readFileSync(__dirname + '/public/js/main.js');
var mainCss = fs.readFileSync(__dirname + '/public/css/main.css');
var headersHtml = {
'Content-Type' : 'text/html'
};
var headersJs = {
'Content-Type' : 'text/js'
};
var headersCss = {
'Content-Type' : 'text/css'
};
handler.home = function(req, res){
res.writeHead(200, headersHtml);
res.end(index);
};
handler.notFound = function(req, res){
res.writeHead(404, headersHtml);
res.end('Resource not found');
};
handler.favicon = function(req, res){
res.writeHead(200, headersHtml);
res.end();
};
handler.index = function(req, res) {
res.writeHead(200, headersHtml);
res.end(index);
};
handler.mainJs = function(req, res){
res.writeHead(200, headersJs);
res.end(mainJs);
};
handler.mainCss = function(req, res){
res.writeHead(200, headersCss);
res.end(mainCss);
};