Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Motivation In the previous weeks we have covered mostly front-end development. This includes creating HTML webpages with CSS stylings. You have also practiced sending out

Motivation

In the previous weeks we have covered mostly front-end development. This includes creating HTML webpages with CSS stylings. You have also practiced sending out HTTP requests to external servers. This week you are going to be creating a simple web server to handle HTTP requests. This is what is called back-end development.

Description

This week you will write a web application that will receive incoming POST and GET requests. You will write a single server to handle BOTH types of requests (i.e. the use the same URL).

The server needs to do the following:

  • Upon receiving a POST request
    • "Render" a page that has a H1 tag displaying "POST Request Received"
  • Upon receiving a GET request
    • "Render" a page that has a H1 tag displaying "GET Request Received"
  • For both POST and GET
    • Below the H1 tag, create an HTML table that shows all parameter names and values which were sent in the URL query string for BOTH GET and POST (you can still send parameters in the URL when making POST requests)
  • For POST:
    • Below the URL parameter table, create another table that displays the property names and values that were received in the request body. Your server needs to be able to accept request bodies formatted as BOTH URL encoded query strings or JSON data.

Hints:

  • You will need two route handlers that have the same target URL (e.g. '/'): one for GET and one for POST
  • You may directly create HTML on your server and send it back to the browser or you may use Handlebar templates
  • As an exception to the general rule you can copy and paste the code from the lecture without citing or explaining it. This does not apply to the routes used for the GET and POST submissions. So all the boilerplate code about setting up handlebars, handling 404's, launching the app can all be copied because it is really boring and you will be using it a lot. The handlers for the routes providing the data should not be copied from the lectures.
  • To test (only POST) key-value pairs sent in the body, you need to use an HTTP POST request. You could do this via a Javascript call, but it might be easier to use a Chrome plugin like Advanced Rest Client (Links to an external site.) (ARC) to get a GUI interface you can play with.
  • Please note that the GET request only requires a single table, but POST requests may require two tables: one for a query string and one for POST bodies.

What to turn in

  • zip with your files
  • URL to your live and running server as a submission comment

You should submit a single zip file containing all of your source code. The file must be named ".zip" (e.g. iannie.zip).

This should include the .js files, your package.json file, and the directories containing your views, templates and static files. Do not include the node_modules directories in this zip file.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions

Question

What is the IPCC, and what is its function?

Answered: 1 week ago

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago