Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

having trouble with running the code on python. I get a bunch of errors. I am trying to run code importing socket to webserver I

having trouble with running the code on python. I get a bunch of errors. I am trying to run code importing socket to webserver I have the html file. I will attach my code. please helpimage text in transcribed

#import socket module from socket import* import sys # In order to terminate the program serverSocketsocket (AF INET, SOCK STREAM) #Prepare a sever socket #Fill in start serverPort12000 serverSocket.bind ( ('", serverPort)) serverSocket.listen (1) #Fill in end while True: print ('Ready to serve...') connectionSocket, addr - serverSocket.accept () try: message-connectionSocket.recv (1024) .decode () filename-message.split ) [1] f = open (filename [1: ] ) outputdata -f.read () connectionSocket . send (bytes ( ' HTTP/ 1 . x 200 connectionSocket.send (" ".encode ()) OK ' , ' UTF-8" ) ) for i in range (0, len (outputdata)): connectionSocket.send (outputdata[i].encode ()) connectionSocket.send (" " .encode ()) connectionSocket.close () except TOError: connectionSocket.send ('n404 File Not Found '.encode ()) connectoinSocket.close () serverSocket.close () sys .extit()#Terminate the program after sending the corresponding data

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Principles Of Multimedia Database Systems

Authors: V.S. Subrahmanian

1st Edition

1558604669, 978-1558604667

More Books

Students explore these related Databases questions