From e1994b6e0342913696f94eec1a4a6b0685e3a015 Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Thu, 15 Apr 2021 11:36:55 -0500 Subject: hw6 --- csci4131/hw6/strap012_hw6/index.js | 39 ++++++- csci4131/hw6/strap012_hw6/package.json | 2 +- csci4131/hw6/strap012_hw6/public/addContact.html | 113 +++++++++++++++++++++ csci4131/hw6/strap012_hw6/public/contacts.html | 73 ++++++++++++++ csci4131/hw6/strap012_hw6/public/login.html | 38 +++++++ csci4131/hw6/strap012_hw6/public/stock.html | 123 +++++++++++++++++++++++ csci4131/lec/Lec23Ex1.xml | 5 + 7 files changed, 390 insertions(+), 3 deletions(-) create mode 100644 csci4131/hw6/strap012_hw6/public/addContact.html create mode 100644 csci4131/hw6/strap012_hw6/public/contacts.html create mode 100644 csci4131/hw6/strap012_hw6/public/login.html create mode 100644 csci4131/hw6/strap012_hw6/public/stock.html create mode 100644 csci4131/lec/Lec23Ex1.xml (limited to 'csci4131') diff --git a/csci4131/hw6/strap012_hw6/index.js b/csci4131/hw6/strap012_hw6/index.js index a81fbd1..6ce24c2 100644 --- a/csci4131/hw6/strap012_hw6/index.js +++ b/csci4131/hw6/strap012_hw6/index.js @@ -39,7 +39,7 @@ app.use(session({ // middle ware to serve static files app.use(express.static(path.join(__dirname, 'public'))); -// server listens on port 9002 for incoming connections +// server listens on port for incoming connections app.listen(port, () => console.log('Listening on port', port)); app.get('/', function (req, res) { @@ -49,11 +49,46 @@ app.get('/', function (req, res) { // GET method route for the contacts page. // It serves contact.html present in public folder app.get('/contacts', function(req, res) { - // TODO: Add Implementation + if(!req.session.value) { + res.redirect('/login'); + } else { + res.sendFile(path.join(__dirname, 'public/contacts.html')); + } +}); + +app.get('/stock', function (req, res) { + if (!req.session.value) { + res.redirect('/login'); + } else { + res.sendFile(path.join(__dirname, 'public/stock.html')); + } +}); + +app.get('/addContact', function (req, res) { + if (!req.session.value) { + res.redirect('/login'); + } else { + res.sendFile(path.join(__dirname, 'public/addContact.html')); + } +}); + +app.get('/login', function (req, res) { + if (req.session.value) { + res.redirect('/contacts'); + } else { + res.sendFile(path.join(__dirname, 'public/login.html')); + } +}); + +app.post('/logintry', function(req, res) { + }); + // TODO: Add implementation for other necessary end-points + + // Makes Express use a router called utilities app.use('/api', utilities); diff --git a/csci4131/hw6/strap012_hw6/package.json b/csci4131/hw6/strap012_hw6/package.json index a6f8b37..db9cf8f 100644 --- a/csci4131/hw6/strap012_hw6/package.json +++ b/csci4131/hw6/strap012_hw6/package.json @@ -4,7 +4,7 @@ "description": "Assignment 6", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "node index.js" }, "author": "strap012", "license": "ISC", diff --git a/csci4131/hw6/strap012_hw6/public/addContact.html b/csci4131/hw6/strap012_hw6/public/addContact.html new file mode 100644 index 0000000..12bfaa2 --- /dev/null +++ b/csci4131/hw6/strap012_hw6/public/addContact.html @@ -0,0 +1,113 @@ + + + + + + + + + + + + + +

+ +
+
+


+
+ +
+
+
+
+
+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Name +
+ +
+
Category +
+ +
+
Location +
+ +
+
Contact Information +
+ +
+
Email +
+ +
+
Website Name +
+ +
+
Website URL +
+ +
+
+ +
+
+
+
+
+
+
+ + diff --git a/csci4131/hw6/strap012_hw6/public/contacts.html b/csci4131/hw6/strap012_hw6/public/contacts.html new file mode 100644 index 0000000..15e4032 --- /dev/null +++ b/csci4131/hw6/strap012_hw6/public/contacts.html @@ -0,0 +1,73 @@ + + + + + + + + + + + +

+ +
+ + + + + + + + + + + + +
NameCategoryLocationContact InformationEmailWebsite
(URL)
+
+ + + diff --git a/csci4131/hw6/strap012_hw6/public/login.html b/csci4131/hw6/strap012_hw6/public/login.html new file mode 100644 index 0000000..34bbc8c --- /dev/null +++ b/csci4131/hw6/strap012_hw6/public/login.html @@ -0,0 +1,38 @@ + + + + + + + +
+
+ + +
+
+ + +
+ +
+ + + \ No newline at end of file diff --git a/csci4131/hw6/strap012_hw6/public/stock.html b/csci4131/hw6/strap012_hw6/public/stock.html new file mode 100644 index 0000000..b55ffcb --- /dev/null +++ b/csci4131/hw6/strap012_hw6/public/stock.html @@ -0,0 +1,123 @@ + + + + + + + + + + + + + +

+ +
+
+
Welcome to Stock Page
+
+
+ +
+
+
+ + + + + + + + + + +
Company +
+ +
+
+ +
+
+
+
+ +
+
+
+ +
+ + + + + + + +
+      
+ +
Company-MetaDataStock-Info
+
+ + + + diff --git a/csci4131/lec/Lec23Ex1.xml b/csci4131/lec/Lec23Ex1.xml new file mode 100644 index 0000000..5568c44 --- /dev/null +++ b/csci4131/lec/Lec23Ex1.xml @@ -0,0 +1,5 @@ + + + Honda Civic + 2001 + \ No newline at end of file -- cgit v1.2.3