Skip to content

Build a web application using Node and Express

Mikael Roos edited this page Jan 30, 2020 · 2 revisions

This is the assignment A04 for "Section 04: Server side JavaScript with Node and Express".

You should save your work in work/s04/a04.

Prerequisites

You have worked though the following articles.

Information

You should use the experienced gained from the above articles to produce a website, or web application, using JavaScript, Node and Express.

The lottery Lotto is a swedish game lottery. It will be used as the base for this assignment.

Requirements grade 3

  1. You should create an Express application that can be started using node index and it should run on port 1337.

  2. Add a copy of your work/report so it can be accessed through the path report.html.

  3. Add a path lotto that prints out a web page showing a lotto draw, a serie of 7 numbers, all between 1 and 35.

  4. Organise your code in files and modules.

Requirements grade 4

  1. Do all requirements for grade 3.

  2. Add the path lotto-json which produces a JSON response of the lotto draw.

  3. Enable to send in your own lotto row, through the query string, like this lotto-json?row=1,3,7,9,28,33,35

  4. The JSON response should contain the data of your own row of numbers.

  5. The JSON response should contain how many numbers you had correct.

Requirements grade 5

  1. Do all requirements for grade 4.

  2. Enable to send in your row through the query string, using lotto?row=1,3,7,9,28,33,35.

  3. Update the web page and do a nice output showing a table where your own numbers are marked.

  4. Update the web page and do another nice output showing a table where the actual number from the lotto draw, are marked.

  5. Add to the page, a message showing how many correct numbers you had.

Optional and for the fun of showing off

This exercise connects client side fetch() (A03) with the server side JSON REST API (grade 4 above).

  1. Add a page lotto.html that has client side JavaScript where the user can enter a serie of figures through a HTML form element, when a submit button is pressed the row is sent to the server, through lotto-json. The JSON response is retreieved in the page, and without reloading the page it is updated showing how many hits you had with your lotto serie.