$30
In this assignment you will build the foundation for the web server you will build throughout this course. You will become familiar with the basics of HTTP and Docker.
Objective 1: Docker
You will setup your web server to deploy with docker. In the root directory of your submission, include a Dockerfile with everything needed to create an image and run your server in a container.
● Expose port 8000 and run your app on this port
Testing Procedure
The testing procedure for each objective will be followed by the course staff while grading your submission.
Download your submission and extract the zip file in a new directory
cd into to the directory containing your submission
Build the docker image “docker build -t <image_name .” with the tester’s choice for <image_name
Create and run a docker container “docker container run --publish <local_port:8000 --detach <image_name” with the tester’s choice for <local_port.
Verify that the image built and ran without error
Note: Later objectives will be tested by opening a browser and navigating to http://localhost:<local_port/<path after running your Docker container
You should use these steps to ensure that your Dockerfile is setup properly to run your server.
Objective 2: Hello World!
Write a TCP socket server in your chosen language and implement an HTTP server that will welcome users to your brand new site. When a user makes a GET request for the path “/hello” your server should respond with a welcoming message of your choice in a properly formatted HTTP response. The message type should be plain text (eg. content type “text/plain”).
Example: GET /hello returns “Hello World!”
Testing Procedure
Start your server using the procedure in objective 1
Open a browser and navigate to http://localhost:<local_port/hello
Verify that the browser displays a welcoming message
Open the browser console and verify that response has a response code of 200 OK, the content-type is text/plain, and the content-length contains the correct value
Objective 3: 301 Redirect
Add a path of “/hi” to your server that redirects to “/hello”.
Testing Procedure
Start your server using the procedure in objective 1
Open a browser and navigate to http://localhost:<local_port/hi
Verify that the browser displays a welcoming message
Open the browser console and verify that 2 HTTP requests were made. The first, for “/hi” has a response code of 301 and the second, for “/hello” has a response code of 200
Objective 4: 404 Not Found
If a request is received for any path other than “/hello” or “/hi”, return a 404 response with a message saying that the content was not found. This can be a plain text message.
Testing Procedure
Start your server using the procedure in objective 1
Open a browser and navigate to http://localhost:<local_port/<any_string where <any_string is chosen by the tester and is anything other than “hello” or “hi”. Note that it can be the empty string
Verify that the browser displays a message indicating that the requested content was not found
Open the browser console and verify that response has a response code of 404 Not Found, the content-type matches the type of content served, and the content-length contains the correct value
Submission
Submit all files for your server to AutoLab in a zip file. Be sure to include:
● A Dockerfile in the root directory
● A file named “report.txt” in the root directory explaining the architecture of your code
Grading
Each objective is equally weighted and will scored on a 0-3 scale as follows:
3
Clearly correct. Following the testing procedure results in all expected behavior
2
Mostly correct, but with some minor issues. Following the testing procedure does not give the exact expected results
1
Clearly incorrect, but an honest attempt was made to complete the objective. Following the testing procedure gives completely incorrect results or no results at all
0
No attempt to complete the objective or violation of the assignment (Ex. Using an HTTP library)
The following conversions will be used when translating grades on this 0-3 scale to percentage grades:
3
100%
2
80%
1
60%
0
0%