From c3ff1b6faf77df903fa55cc05bcbdde263d1045a Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Sat, 20 Mar 2021 17:22:20 -0500 Subject: Start HW5 --- csci4131/hw5/strap012_hw5/createServer.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'csci4131/hw5/strap012_hw5/createServer.js') diff --git a/csci4131/hw5/strap012_hw5/createServer.js b/csci4131/hw5/strap012_hw5/createServer.js index 01f1f08..8f79c9f 100755 --- a/csci4131/hw5/strap012_hw5/createServer.js +++ b/csci4131/hw5/strap012_hw5/createServer.js @@ -9,7 +9,8 @@ http.createServer(function (req, res) { var q = url.parse(req.url, true); var filename = "." + q.pathname; if(req.url === '/'){ - indexPage(req,res); + res.writeHead(302, { 'Location': 'contacts.html' }); + return res.end("302 Temporary Redirect"); } else if (req.url === '/index.html') { indexPage(req, res, '/index.html'); @@ -21,7 +22,13 @@ http.createServer(function (req, res) { indexPage(req, res, '/addContact.html'); } else if (req.url === '/stock.html') { - jsonSock(req, res, '/stock.html'); + indexPage(req, res, '/stock.html'); + } + else if (req.url === '/contacts.json') { + jsonSock(req, res, 'contacts.json') + } + else if (req.url === "/postContactEntry") { + } else{ res.writeHead(404, {'Content-Type': 'text/html'}); @@ -43,7 +50,7 @@ function indexPage(req, res, file) { } function jsonSock(req, res, file) { - fs.readFile('client/' + file, function (err, json) { + fs.readFile(file, function (err, json) { if (err) { throw err; } -- cgit v1.2.3