-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.js
31 lines (26 loc) · 924 Bytes
/
main.js
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
var http = require('http');
var fs = require('fs');
const port = 8000
http.createServer(function (request, response) {
console.log('request starting...');
var filePath = './temp/chunks' + request.url;
fs.readFile(filePath, function(error, content) {
response.writeHead(200, { 'Access-Control-Allow-Origin': '*' });
if (error) {
if(error.code == 'ENOENT'){
fs.readFile('./404.html', function(error, content) {
response.end(content, 'utf-8');
});
}
else {
response.writeHead(500);
response.end('Sorry, check with the site admin for error: '+error.code+' ..\n');
response.end();
}
}
else {
response.end(content, 'utf-8');
}
});
}).listen(port);
console.log(`Server running at http://127.0.0.1:${port}/`);