Question: Below you will find the skeleton code for the Web server. You are to complete the skeleton code or build your own code. In the

Below you will find the skeleton code for the Web server. You are to complete the skeleton code or build your own code. In the skeleton code, the places where you need to fill in code are marked with #Fill. Each place may require one or more lines of code. (You may need to add additional lines other than the places marked with #Fill. The following just provides an example, you may not follow the example)

Skeleton Python Code for the Web Server

#import socket module

from socket import *

serverSocket = socket(AF_INET, SOCK_STREAM)

#Prepare a sever socket

#Fill

while True:

#Establish the connection

print 'Ready to serve...'

connectionSocket, addr = #Fill

try:

message = #Fill nd

filename = message.split()[1]

f = open(filename[1:])

outputdata = #Fill

#Send one HTTP header line into socket

#Fill

#Send the content of the requested file to the client

for i in range(0, len(outputdata)):

connectionSocket.send(outputdata[i])

connectionSocket.close()

except IOError:

#Send response message for file not found

#Fill

#Close client socket

#Fill

serverSocket.close()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!