[Solved] CSE312 Homework2-Static Site

$25

File Name: CSE312_Homework2-Static_Site.zip
File Size: 263.76 KB

SKU: [Solved] CSE312 Homework2-Static Site Category: Tag:
5/5 - (1 vote)

Now that you have the basics of your HTTP server running, lets host static content using your server. A sample page is provided that you will host so you can focus on the functionality of your server.

Sample site download

Objective 1: Host HTML/CSS/JavaScript

Host index.html, style.css, and functions.js from the sample site or host your own page if you completed the bonus objective. You should host each file at a path equal to its file name if you are using the sample site except index.html should be hosted at the root path.

Each file must be sent with the appropriate MIME type. You may assume that all files only contain ASCII characters.

Testing Procedure

  1. Start your server using Docker
  2. Open a browser and navigate to http://localhost:<local_port>
  3. Verify that the browser displays the website
    1. The image does not have to display for this objective
  4. Check each HTTP response from your server for the correct MIME type
  5. Verify that the X-Content-Type-Options: nosniff header is set on each response

Objective 2: UTF-8

Host the utf.txt file from the sample site as text/plain MIME type at the path /utf.txt. This file contains non-ASCII characters so the content length must be measured carefully. For full credit, you must find the content length programmatically and in a general way that will work for any file (ie. You wont get full credit if you hardcode the content length of utf.txt).

Testing Procedure

  1. Start your server using Docker
  2. Open a browser and navigate to http://localhost:<local_port>/utf.txt
  3. Verify that the browser displays the entire string contained in the file
  4. Verify that the browser is not still loading (This will occur if your content length is larger than the amount of content sent)
  5. Verify in your code that the content length was computed and not hardcoded

Objective 3: Host Images

Host all of the images in the provided in the images directory of the sample site at the path /image/<image_name> where <image_name> is the filename of the requested image including the file extension.

Example: A request for the path /image/kitten.jpg should display this adorable image:

Testing Procedure

  1. Start your server using Docker
  2. Open a browser and navigate to http://localhost:<local_port>
    1. Verify that the image of a flamingo displays properly
  3. Open a browser and navigate to http://localhost:<local_port>/image/<image_name>
    1. <image_name> can be any image provided in the sample site
  4. Verify that the browser displays <image_name>
  5. Verify that the MIME type of your HTTP response is appropriate
  6. Verify that the X-Content-Type-Options: nosniff header is set on the image response

Objective 4: Query String + HTML Templates

At the path /images accept a query string containing containing the keys-value pairs:

  • A key name containing a value that is users name
  • A key images containing a + separated list of image names that the user would like to view
    • Each image name will be the filename for the image without an extension and all request should be treated as requests for .jpg images

When such a request is received your server should serve an HTML page containing a greeting that includes the users name and all of the requested images.

Example: If the request is for /images?images=cat+kitten+dog&name=Mitch you will serve a page with a message welcoming Mitch and the images cat.jpg, kitten.jpg, and dog.jpg.

You may assume the query string will not include any percent-encoded characters.

Testing Procedure

  1. Start your server using Docker
  2. Open a browser and navigate to one of the following:
    1. http://localhost:<local_port>/images?name=<name>&images<image_list>
    2. http://localhost:<local_port>/images?images<image_list>&name=<name>
    3. With any valid choice for <name> and <image_list>. The images in <image_list> will match images in the provided sample site
  3. Verify that the browser displays both a message greeting <name> and all of the images from <image_list>
  4. Verify the MIME type of your HTTP response are appropriate

Bonus Objective: Front End Development

Create your own front end to replace the sample provided for this assignment. Write your own HTML, CSS, and JavaScript and host your image file(s).

Testing Procedure

  1. Start your server using Docker
  2. Open a browser and navigate to http://localhost:<local_port>
  3. Verify that the browser displays a website including HTML, CSS, JavaScript, and at least one image that are all different from the provided sample site
    1. The image must be served by your server using a relative path (Do not set the src of the img to a full url)

Reviews

There are no reviews yet.

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

Shopping Cart
[Solved] CSE312 Homework2-Static Site
$25