Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 5547d0f

Browse files
committed
deploy to herku
1 parent 909ffb4 commit 5547d0f

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: node server.js

server.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
var http = require('http');
2+
var fs = require('fs');
3+
var path = require('path');
4+
5+
var server = http.createServer(function (request, response) {
6+
var filePath = '.' + request.url;
7+
if (filePath == './')
8+
filePath = './index.html';
9+
10+
var extname = path.extname(filePath);
11+
var contentType = 'text/html';
12+
switch (extname) {
13+
case '.js':
14+
contentType = 'text/javascript';
15+
break;
16+
case '.css':
17+
contentType = 'text/css';
18+
break;
19+
case '.json':
20+
contentType = 'application/json';
21+
break;
22+
case '.png':
23+
contentType = 'image/png';
24+
break;
25+
case '.jpg':
26+
contentType = 'image/jpg';
27+
break;
28+
case '.wav':
29+
contentType = 'audio/wav';
30+
break;
31+
}
32+
33+
fs.readFile(filePath, function(error, content) {
34+
if (error) {
35+
if(error.code == 'ENOENT'){
36+
fs.readFile('./404.html', function(error, content) {
37+
response.writeHead(200, { 'Content-Type': contentType });
38+
response.end(content, 'utf-8');
39+
});
40+
}
41+
else {
42+
response.writeHead(500);
43+
response.end('Sorry, check with the site admin for error: '+error.code+' ..\n');
44+
response.end();
45+
}
46+
}
47+
else {
48+
response.writeHead(200, { 'Content-Type': contentType });
49+
response.end(content, 'utf-8');
50+
}
51+
});
52+
53+
})
54+
55+
var port = Number(process.env.PORT || 3000);
56+
57+
server.listen(port);
58+
59+

0 commit comments

Comments
 (0)