HTTP is the basis for all Web communication.
Web servers must implement the basic HTTP methods appropriately.
Do the following exercises.
Use Express, as described here: Basic routing, to implement the following:
localhost:3000/request
.
my_application.all()
to
set/return them.
Demonstrate that your server can handle the requests, including the passage of data to the methods that support data. Do this, if possible, using both of these tools:
curl [--head] URL
- GET the specified URL; the head option gets only the header.
curl -X method URL -d data -H 'Content-Type: application/json'
- Send the specified HTTP method/data to the specified URL. Here, the data is declared to be in JSON format, e.g.,
'{"arg":"value"}'
.
You can use the NPM body-parser to parse JSON data on the server side; see the sample code for an example of how to do this.
Record which tool (Chrome and/or curl) could be used for each of the HTTP methods. Also record the Curl commands you used successfully (include them in the lab text file below).
When that is done, consider the following questions.
Save your answers to these questions in a lab06.txt
file in
the root of your lab repo.
HTML Forms are a fundamental input mechanism for web apps.
Work through the tutorial specified here: My first HTML form. Note the following.
public/forms
sub-directory.
/forms
route.
When that is done, consider the following questions.
Save your answers to these questions in your lab06.txt
file.
We will grade your work according to the following criteria: