diff --git a/README.md b/README.md index 29b1d71..ed27421 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # assignment_build_a_nodejs_server Building your first Node.js server and exploring the request and response objects + +Brian Gallagher diff --git a/app.js b/app.js new file mode 100644 index 0000000..413762e --- /dev/null +++ b/app.js @@ -0,0 +1,26 @@ +var http = require('http'); +var fs = require('fs'); + +var port = 3000; +var host = 'localhost'; + + +var server = http.createServer(function(req, res) { + fs.readFile('./public/index.html', 'utf8', function(err, data) { + if (err) { + res.writeHead(404); + res.end("404 Not Found"); + } else { + res.writeHead(200, { + "Content-Type": "text/html" + console.log(String.prototype.replace(req)); + console.log(JSON.stringify(req.pre)); + }); + res.end(data); + } + }); +}); + +server.listen(port, host, function() { + console.log(`Listening at http://${ host }:${ port }`); +}); diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..08fdc5d --- /dev/null +++ b/public/index.html @@ -0,0 +1,12 @@ + + +
+ + + +