diff options
author | RossTheRoss <mstrapp@protonmail.com> | 2021-03-20 17:22:20 -0500 |
---|---|---|
committer | RossTheRoss <mstrapp@protonmail.com> | 2021-03-20 17:22:20 -0500 |
commit | c3ff1b6faf77df903fa55cc05bcbdde263d1045a (patch) | |
tree | 65b6250fbb08d2a3d2a806a5d0427a17070c7e51 /csci4131/hw5/strap012_hw5/createServer.js | |
parent | Make resume (diff) | |
download | homework-c3ff1b6faf77df903fa55cc05bcbdde263d1045a.tar homework-c3ff1b6faf77df903fa55cc05bcbdde263d1045a.tar.gz homework-c3ff1b6faf77df903fa55cc05bcbdde263d1045a.tar.bz2 homework-c3ff1b6faf77df903fa55cc05bcbdde263d1045a.tar.lz homework-c3ff1b6faf77df903fa55cc05bcbdde263d1045a.tar.xz homework-c3ff1b6faf77df903fa55cc05bcbdde263d1045a.tar.zst homework-c3ff1b6faf77df903fa55cc05bcbdde263d1045a.zip |
Start HW5
Diffstat (limited to '')
-rwxr-xr-x | csci4131/hw5/strap012_hw5/createServer.js | 13 |
1 files changed, 10 insertions, 3 deletions
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;
}
|