[Solved] CSE312 Homework1

$25

File Name: CSE312_Homework1.zip
File Size: 150.72 KB

SKU: [Solved] CSE312 Homework1 Category: Tag:
5/5 - (1 vote)

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.
  1. Download your submission and extract the zip file in a new directory
  2. cd into to the directory containing your submission
  3. Build the docker image docker build -t <image_name> . with the testers choice for <image_name>
  4. Create and run a docker container docker container run publish <local_port>:8000 detach <image_name> with the testers choice for <local_port>.
  5. Verify that the image built and ran without error
    1. 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

  1. Start your server using the procedure in objective 1
  2. Open a browser and navigate to http://localhost:<local_port>/hello
  3. Verify that the browser displays a welcoming message
  4. 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

  1. Start your server using the procedure in objective 1
  2. Open a browser and navigate to http://localhost:<local_port>/hi
  3. Verify that the browser displays a welcoming message
  4. 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

  1. Start your server using the procedure in objective 1
  2. 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
  3. Verify that the browser displays a message indicating that the requested content was not found
  4. 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

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSE312 Homework1
$25