Develop a small web server that


Develop a small web server that does the following:

•Handles only one HTTP request at a time;
•Accepts and parses the HTTP request;
•Gets the requested file from the server's file system;
•Creates an HTTP response message consisting of the requested file preceded by header lines;
•Sends the response directly to the requesting browser.

Below you will find the skeleton code for your Web server. The places where you need to fill in code are marked with #Fill in start and #Fill in end. Each place may require one or more lines of code.

#import socket module

from socket import * 

serverSocket = socket(AF_INET, SOCK_STREAM)

#Prepare a sever socket

#Fill in start


#Fill in end

while True:

#Establish the connection

print 'Ready to serve...'

connectionSocket, addr = # Fill in start #Fill in end 

try:

message = #Fill in start #Fill in end 

filename = message.split()[1] 

f = open(filename[1:]) 

outputdata = #Fill in start #Fill in end 

#Send one HTTP header line into socket

#Fill in start


#Fill in end 

#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 in start

#Fill in end

#Close client socket

#Fill in start


#Fill in end 

serverSocket.close()

Request for Solution File

Ask an Expert for Answer!!
Computer Networking: Develop a small web server that
Reference No:- TGS0138349

Expected delivery within 24 Hours