Created
August 6, 2012 20:00
-
-
Save jaeschrich/3277994 to your computer and use it in GitHub Desktop.
Node.js project boilerplate.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> <!-- based on HTML5 Boilerplate and Twitter Bootstrap starter template --> | |
<head> | |
<!-- You should probably use a local version of html5shim here. --> | |
<!--[if lt IE 9]> | |
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> | |
<![endif]--> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
<title>Envy</title> | |
<meta name="description" content=""> | |
<meta name="viewport" content="width=device-width"> | |
</head> | |
<body> | |
404: Not found. Sorry :( | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> <!-- based on HTML5 Boilerplate and Twitter Bootstrap starter template --> | |
<head> | |
<!-- You should probably use a local version of html5shim here. --> | |
<!--[if lt IE 9]> | |
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> | |
<![endif]--> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
<title>Envy</title> | |
<meta name="description" content=""> | |
<meta name="viewport" content="width=device-width"> | |
</head> | |
<body> | |
Hello World | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require("http") | |
var fs = require('fs') | |
var url = require('url') | |
http.createServer(function(req, res){ | |
console.log("Request for "+req.url+"recieved.") | |
var path = url.parse(req.url).pathname | |
switch(path){ | |
case '/': | |
fs.readFile('index.html', function(err, data){ | |
if (err){console.log(err)} | |
res.writeHead(200, {"Content-Type": 'text/html'}) | |
res.end(data) | |
}) | |
break; | |
default: | |
fs.readFile('404.html', function(err, data){ | |
if (err){console.log(err)} | |
res.writeHead(200, {"Content-Type": 'text/html'}) | |
res.end(data) | |
console.log("404 error for "+req.url) | |
}) | |
break; | |
} | |
}).listen(8080) | |
console.log("Server Started") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment