diff --git a/README.md b/README.md index 3945c152..bb6c45ba 100755 --- a/README.md +++ b/README.md @@ -1,93 +1,30 @@ -Assignment 2 - Short Stack: Basic Two-tier Web Application using HTML/CSS/JS and Node.js -=== - -Due: September 16th, by 11:59 PM. - -This assignment aims to introduce you to the concepts and practice involved in creating a prototype (i.e. not deployment ready) two-tiered web application. The baseline aims of this assignment involve creating an application that demonstrates the use of several specific pieces of HTML, CSS, JavaScript, and Node.js functionality. - -Baseline Requirements +# Assignment 2 - Short Stack: Basic Two-tier Web Application using HTML/CSS/JS and Node.js --- -Note that there is a very large range of application areas and possibilities that meet these baseline requirements. Make your application do something useful! A todo list, storing / retrieving high scores for a very simple game, have a little fun with it. - -Your application is required to implement the following functionalities: - -- a `Server` which not only serves files, but also maintains a tabular dataset with 3 or more fields related to your application -- a `Results` functionality which shows the entire dataset residing in the server's memory -- a `Form/Entry` functionality which allows a user to add, modify, or delete data items residing in the server's memory -- a `Server Logic` which, upon receiving new or modified "incoming" data, includes and uses a function that adds at least one additional derived field to this incoming data before integrating it with the existing dataset -- the `Derived field` for a new row of data must be computed based on fields already existing in the row. For example, a `todo` dataset with `task`, `priority`, and `creation_date` may generate a new field `deadline` by looking at `creation_date` and `priority` - -Your application is required to demonstrate the use of the following concepts: +https://a2-hezi-k.glitch.me -HTML: -- One or more [HTML Forms](https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms), with any combination of form tags appropriate for the user input portion of the application -- A results page displaying all data currently available on the server. You will most likely use a `` tag for this, but `
+ + + + + + + + + +
NicknameUsernamePasswordPref. FootPositonDate JoinedDelete
+ + + + + diff --git a/server.improved.js b/server.improved.js index 26673fc0..5a077476 100644 --- a/server.improved.js +++ b/server.improved.js @@ -7,25 +7,37 @@ const http = require( 'http' ), port = 3000 const appdata = [ - { 'model': 'toyota', 'year': 1999, 'mpg': 23 }, - { 'model': 'honda', 'year': 2004, 'mpg': 30 }, - { 'model': 'ford', 'year': 1987, 'mpg': 14} -] + { id: 0, username: "Hezi", Password: "hello", Foot: "left", Position: "def", dateJoined: "2020-9-21" } +]; + +let playerPage = null; +fs.readFile("public/players.html", function(err, content) { + playerPage = content; +}); const server = http.createServer( function( request,response ) { if( request.method === 'GET' ) { - handleGet( request, response ) + handleGet( request, response ) }else if( request.method === 'POST' ){ - handlePost( request, response ) + handlePost( request, response ) } }) const handleGet = function( request, response ) { - const filename = dir + request.url.slice( 1 ) - + const filename = dir + request.url.slice( 1 ) if( request.url === '/' ) { sendFile( response, 'public/index.html' ) - }else{ + } + else if( request.url === "/players") { + sendFile( response, "public/players.html") + } + else if( request.url === "/game") { + sendFile( response, "public/game.html"); + } + else if(request.url === "/style.css") { + sendFile( response, "public/css/style.css"); + } + else{ sendFile( response, filename ) } } @@ -34,7 +46,7 @@ const handlePost = function( request, response ) { let dataString = '' request.on( 'data', function( data ) { - dataString += data + dataString += data }) request.on( 'end', function() { @@ -48,7 +60,7 @@ const handlePost = function( request, response ) { } const sendFile = function( response, filename ) { - const type = mime.getType( filename ) + const type = mime.getType( filename ) fs.readFile( filename, function( err, content ) {