From 7a73162607544204032aa66cce755daf21edebda Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Tue, 24 May 2022 11:18:46 -0500 Subject: Graduate Signed-off-by: Matt Strapp --- .../hw5/strap012_hw5/client/addContact.html | 113 ------------------- OLD/csci4131/hw5/strap012_hw5/client/contacts.html | 73 ------------ OLD/csci4131/hw5/strap012_hw5/client/index.html | 27 ----- OLD/csci4131/hw5/strap012_hw5/client/stock.html | 123 --------------------- OLD/csci4131/hw5/strap012_hw5/contacts.json | 22 ---- OLD/csci4131/hw5/strap012_hw5/createServer.js | 90 --------------- OLD/csci4131/hw5/strap012_hw5/package.json | 11 -- 7 files changed, 459 deletions(-) delete mode 100644 OLD/csci4131/hw5/strap012_hw5/client/addContact.html delete mode 100644 OLD/csci4131/hw5/strap012_hw5/client/contacts.html delete mode 100644 OLD/csci4131/hw5/strap012_hw5/client/index.html delete mode 100644 OLD/csci4131/hw5/strap012_hw5/client/stock.html delete mode 100644 OLD/csci4131/hw5/strap012_hw5/contacts.json delete mode 100644 OLD/csci4131/hw5/strap012_hw5/createServer.js delete mode 100644 OLD/csci4131/hw5/strap012_hw5/package.json (limited to 'OLD/csci4131/hw5/strap012_hw5') diff --git a/OLD/csci4131/hw5/strap012_hw5/client/addContact.html b/OLD/csci4131/hw5/strap012_hw5/client/addContact.html deleted file mode 100644 index 12bfaa2..0000000 --- a/OLD/csci4131/hw5/strap012_hw5/client/addContact.html +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - - - - - - - - -

- -
-
-


-
- -
-
-
-
-
-

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Name -
- -
-
Category -
- -
-
Location -
- -
-
Contact Information -
- -
-
Email -
- -
-
Website Name -
- -
-
Website URL -
- -
-
- -
-
-
-
-
-
-
- - diff --git a/OLD/csci4131/hw5/strap012_hw5/client/contacts.html b/OLD/csci4131/hw5/strap012_hw5/client/contacts.html deleted file mode 100644 index 15e4032..0000000 --- a/OLD/csci4131/hw5/strap012_hw5/client/contacts.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - -

- -
- - - - - - - - - - - - -
NameCategoryLocationContact InformationEmailWebsite
(URL)
-
- - - diff --git a/OLD/csci4131/hw5/strap012_hw5/client/index.html b/OLD/csci4131/hw5/strap012_hw5/client/index.html deleted file mode 100644 index 44c5d0f..0000000 --- a/OLD/csci4131/hw5/strap012_hw5/client/index.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - -


-
-
-
Welcome to Contact Management
-
-
- - diff --git a/OLD/csci4131/hw5/strap012_hw5/client/stock.html b/OLD/csci4131/hw5/strap012_hw5/client/stock.html deleted file mode 100644 index b55ffcb..0000000 --- a/OLD/csci4131/hw5/strap012_hw5/client/stock.html +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - -

- -
-
-
Welcome to Stock Page
-
-
- -
-
-
- - - - - - - - - - -
Company -
- -
-
- -
-
-
-
- -
-
-
- -
- - - - - - - -
-      
- -
Company-MetaDataStock-Info
-
- - - - diff --git a/OLD/csci4131/hw5/strap012_hw5/contacts.json b/OLD/csci4131/hw5/strap012_hw5/contacts.json deleted file mode 100644 index 54149e8..0000000 --- a/OLD/csci4131/hw5/strap012_hw5/contacts.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "contacts": [ - { - "name": "President Joan T.A. Gabel", - "category": "Academic", - "location": "202 Morrill Hall\r\n100 Church Street SE\r\nMinneapolis, MN 55455", - "contact": "President of the University of Minnesota System", - "email": "upres@umn.edu", - "website_name": "Home Page", - "website_url": "https://president.umn.edu/" - }, - { - "name": "Professor Dan Challou", - "category": "Academic", - "location": "383 Shepherd Laboratory\r\n100 Union Street SE\r\nMinneapolis, MN 55455", - "contact": "Professor of CSCI 4131 - Internet Programming", - "email": "chal0006@umn.edu", - "website_name": "Course Home Page", - "website_url": "https://canvas.umn.edu/courses/217376" - } - ] -} diff --git a/OLD/csci4131/hw5/strap012_hw5/createServer.js b/OLD/csci4131/hw5/strap012_hw5/createServer.js deleted file mode 100644 index 9c108cd..0000000 --- a/OLD/csci4131/hw5/strap012_hw5/createServer.js +++ /dev/null @@ -1,90 +0,0 @@ - -const http = require('http'); -const url = require('url'); -const fs = require('fs'); -const qs = require('querystring'); - -const port = 9001; -http.createServer(function (req, res) { - var q = url.parse(req.url, true); - var filename = "." + q.pathname; - if(req.url === '/'){ - res.writeHead(301, { 'Location': 'index.html' }); - return res.end("301 Permanent Redirect"); - } - else if (req.url === '/index.html') { - indexPage(req, res, '/index.html'); - } - else if (req.url === '/contacts.html') { - indexPage(req, res, '/contacts.html'); - } - else if (req.url === '/addContact.html') { - indexPage(req, res, '/addContact.html'); - } - else if (req.url === '/stock.html') { - indexPage(req, res, '/stock.html'); - } - else if (req.url === '/contacts.json') { - jsonSock(req, res, 'contacts.json') - } - else if (req.url === "/postContactEntry") { - POST(req, res); - res.writeHead(302, { 'Location': 'contacts.html' }); - return res.end("302 Temporary Redirect"); - } - else{ - res.writeHead(404, {'Content-Type': 'text/html'}); - return res.end("404 Not Found"); - } -}).listen(port); - -function indexPage(req, res, file) { - fs.readFile('client' + file, function(err, html) { - if(err) { - throw err; - } - res.statusCode = 200; - res.setHeader('Content-type', 'text/html'); - res.write(html); - res.end(); - }); -} - -function jsonSock(req, res, file) { - fs.readFile(file, function (err, json) { - if (err) { - throw err; - } - res.statusCode = 200; - res.setHeader('Content-type', 'text/json'); - res.write(json); - res.end(); - }); -} - -function POST(req, res) { - var reqBody = ''; - // server starts receiving the form data - req.on('data', function(data) { - reqBody+= data; - });// server has received all the form data - req.on('end', function() { - var jsonO = {} - var postObj = qs.parse(reqBody); - jsonO["name"] = postObj.name; - jsonO["category"] = postObj.category; - jsonO["location"] = postObj.location; - jsonO["contact"] = postObj.contact; - jsonO["email"] = postObj.email; - jsonO["website_name"] = postObj.website_name; - jsonO["website_url"] = postObj.website_url; - fs.readFile('./contacts.json', 'utf8', function(err, data) { - var file = JSON.parse(data); - file.contacts.push(jsonO); - var string = JSON.stringify(file); - fs.writeFile('./contacts.json', string, function(err, data) { - console.log(string); - }); //Write clojure - }); //Read clojure - }); //req clojure -} \ No newline at end of file diff --git a/OLD/csci4131/hw5/strap012_hw5/package.json b/OLD/csci4131/hw5/strap012_hw5/package.json deleted file mode 100644 index 90f2542..0000000 --- a/OLD/csci4131/hw5/strap012_hw5/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "strap012_hw5", - "version": "1.0.0", - "description": "Assignment 5", - "main": "createServer.js", - "scripts": { - "test": "node createServer.js" - }, - "author": "strap012", - "license": "ISC" -} -- cgit v1.2.3