SlideShare a Scribd company logo
1 of 2
Download to read offline
The problem can be found below. I would like someone to run this. I don’t get it because there’s
an error. Please, fix this because I don’t know what is happening. What version of python should
I use?
Please, if you don’t know what is happening let someone else to do it. Bp Project untitled
PycharmProjects/untitled 3 import sys ServerPort 80 new server Socket socket (AF INET, S0CK
STREAM) Illi External Libraries 6 #Prepare a sever socket 7 #Fill in start server Socket.bind
server Port)) server Socket.listen (1) print the web server is up on port server Port 10 #Fill in end
11 while True: Establish the connection 13 print "Ready to serve... 14 connectionSocket add J
server Socket. accept() 15 16 try: message connectionSocket.recv(1024) 17 print message
message split 01, message. split 1] 18 filename 3 message. split [1] print filename 'II filename
[1:] 20 open (filename (1:1) 21 output data f.read 22 print outputdata 23 Send one HTTP header
line into socket Fill in start 25 connection Socket.send(' InHTTP/1.1 200 0KNnNn 26
connectionSocket.send(outputdata) 27 Fill in end 28 Send the content of the requested file to the
client 29 for i in range (0, len(outputdata)): 30 connection Socket.send(outputdata [i]) 31
connection Socket.close 32 33 except IOError w Send response message for file not found 34
Fill in start 35 connectionSocket.send NnHTTP/1.1 404 Not Found nAn 36
connectionSocket.send 'InHTTP/1.1 404 Not Found n ') 37 38 39
/Library/Frameworks/Python, framework/Versions/2.7/bin/python2.7 /Users. File User S untitled
new py", line 33 except IOError: SyntaxError: invalid syntax Process finished with exit code 1
Solution
Update your code as below :
#!/bin/python
import sys
import socket
serverPort=80
serverSocket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
serverSocket.bind(('',serverPort))
serverSocket.listen(1)
while True :
connectionSocket, addr = serverSocket.accept()
try :
message = connectionSocket.recv[1024]
filename = message.split()[1]
f = open(filename[1:])
outputdata = f.read()
connectionSocket.send(' HTTP/1.1 200 OK  ')
connectionSocket.send(outputdata)
for i in range(0,len(outputdata)):
connectionSocket.send(outputdata[i])
connectionSocket.close()
except IOError : #indentation is not correct here
connectionSocket.send(' HTTP/1.1 404 Not Found  ')
serverSocket.close();

More Related Content

Similar to The problem can be found below. I would like someone to run this. I .pdf

16network Programming Servers
16network Programming Servers16network Programming Servers
16network Programming Servers
Adil Jafri
 
Please look at the attach See.doc. I am getting this error all th.docx
Please look at the attach See.doc. I am getting this error all th.docxPlease look at the attach See.doc. I am getting this error all th.docx
Please look at the attach See.doc. I am getting this error all th.docx
randymartin91030
 
please code in java- here is a portion of the code if possible please.pdf
please code in java- here is a portion of the code if possible please.pdfplease code in java- here is a portion of the code if possible please.pdf
please code in java- here is a portion of the code if possible please.pdf
a1salesagency
 
CODE FOR echo_client.c A simple echo client using TCP #inc.pdf
CODE FOR echo_client.c A simple echo client using TCP  #inc.pdfCODE FOR echo_client.c A simple echo client using TCP  #inc.pdf
CODE FOR echo_client.c A simple echo client using TCP #inc.pdf
secunderbadtirumalgi
 

Similar to The problem can be found below. I would like someone to run this. I .pdf (20)

16network Programming Servers
16network Programming Servers16network Programming Servers
16network Programming Servers
 
network programing lab file ,
network programing lab file ,network programing lab file ,
network programing lab file ,
 
Please look at the attach See.doc. I am getting this error all th.docx
Please look at the attach See.doc. I am getting this error all th.docxPlease look at the attach See.doc. I am getting this error all th.docx
Please look at the attach See.doc. I am getting this error all th.docx
 
Python networking
Python networkingPython networking
Python networking
 
#1 (TCPvs. UDP)
#1 (TCPvs. UDP)#1 (TCPvs. UDP)
#1 (TCPvs. UDP)
 
please code in java- here is a portion of the code if possible please.pdf
please code in java- here is a portion of the code if possible please.pdfplease code in java- here is a portion of the code if possible please.pdf
please code in java- here is a portion of the code if possible please.pdf
 
اسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونیاسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونی
 
Socket Programming it-slideshares.blogspot.com
Socket  Programming it-slideshares.blogspot.comSocket  Programming it-slideshares.blogspot.com
Socket Programming it-slideshares.blogspot.com
 
Os 2
Os 2Os 2
Os 2
 
python programming
python programmingpython programming
python programming
 
CODE FOR echo_client.c A simple echo client using TCP #inc.pdf
CODE FOR echo_client.c A simple echo client using TCP  #inc.pdfCODE FOR echo_client.c A simple echo client using TCP  #inc.pdf
CODE FOR echo_client.c A simple echo client using TCP #inc.pdf
 
Socket programming
Socket programmingSocket programming
Socket programming
 
Socket.io (part 1)
Socket.io (part 1)Socket.io (part 1)
Socket.io (part 1)
 
Networking & Socket Programming In Java
Networking & Socket Programming In JavaNetworking & Socket Programming In Java
Networking & Socket Programming In Java
 
Network programming Using Python
Network programming Using PythonNetwork programming Using Python
Network programming Using Python
 
Network Programming in Java
Network Programming in JavaNetwork Programming in Java
Network Programming in Java
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
 
Network programming in Java
Network programming in JavaNetwork programming in Java
Network programming in Java
 
Networking.ppt(client/server, socket) uses in program
Networking.ppt(client/server, socket) uses in programNetworking.ppt(client/server, socket) uses in program
Networking.ppt(client/server, socket) uses in program
 
Sockets
Sockets Sockets
Sockets
 

More from SALES97

When acting as a neurotransmitter NO binds to the iron atom in vario.pdf
When acting as a neurotransmitter NO binds to the iron atom in vario.pdfWhen acting as a neurotransmitter NO binds to the iron atom in vario.pdf
When acting as a neurotransmitter NO binds to the iron atom in vario.pdf
SALES97
 
TrueFalse A virtual private network is a way to use the Internet to.pdf
TrueFalse  A virtual private network is a way to use the Internet to.pdfTrueFalse  A virtual private network is a way to use the Internet to.pdf
TrueFalse A virtual private network is a way to use the Internet to.pdf
SALES97
 
The Orlando MedicalOrlando Medical Corporation financial statements.pdf
The Orlando MedicalOrlando Medical Corporation financial statements.pdfThe Orlando MedicalOrlando Medical Corporation financial statements.pdf
The Orlando MedicalOrlando Medical Corporation financial statements.pdf
SALES97
 
The IP network is a virtual network and must rely on a link layer ne.pdf
The IP network is a virtual network and must rely on a link layer ne.pdfThe IP network is a virtual network and must rely on a link layer ne.pdf
The IP network is a virtual network and must rely on a link layer ne.pdf
SALES97
 
State if you agree or disagree with the statement made and whyLes.pdf
State if you agree or disagree with the statement made and whyLes.pdfState if you agree or disagree with the statement made and whyLes.pdf
State if you agree or disagree with the statement made and whyLes.pdf
SALES97
 
subject.....project management.Tools and Processes Based on the pr.pdf
subject.....project management.Tools and Processes Based on the pr.pdfsubject.....project management.Tools and Processes Based on the pr.pdf
subject.....project management.Tools and Processes Based on the pr.pdf
SALES97
 
Read and discuss the following three articles 1. ACAs Perform.pdf
Read and discuss the following three articles 1. ACAs Perform.pdfRead and discuss the following three articles 1. ACAs Perform.pdf
Read and discuss the following three articles 1. ACAs Perform.pdf
SALES97
 

More from SALES97 (20)

Blossom Corporation had 120,000 common shares outstanding on Decembe.pdf
Blossom Corporation had 120,000 common shares outstanding on Decembe.pdfBlossom Corporation had 120,000 common shares outstanding on Decembe.pdf
Blossom Corporation had 120,000 common shares outstanding on Decembe.pdf
 
A system experiences a phase change from liquid to solid. Is this exo.pdf
A system experiences a phase change from liquid to solid. Is this exo.pdfA system experiences a phase change from liquid to solid. Is this exo.pdf
A system experiences a phase change from liquid to solid. Is this exo.pdf
 
Write an equation of a tangent function with the following characters.pdf
Write an equation of a tangent function with the following characters.pdfWrite an equation of a tangent function with the following characters.pdf
Write an equation of a tangent function with the following characters.pdf
 
Why is a mixture of alcohol and water used, rather than simply water.pdf
Why is a mixture of alcohol and water used, rather than simply water.pdfWhy is a mixture of alcohol and water used, rather than simply water.pdf
Why is a mixture of alcohol and water used, rather than simply water.pdf
 
Why are the 1960s relatively turbulentSolutionAnswer1960s .pdf
Why are the 1960s relatively turbulentSolutionAnswer1960s .pdfWhy are the 1960s relatively turbulentSolutionAnswer1960s .pdf
Why are the 1960s relatively turbulentSolutionAnswer1960s .pdf
 
When acting as a neurotransmitter NO binds to the iron atom in vario.pdf
When acting as a neurotransmitter NO binds to the iron atom in vario.pdfWhen acting as a neurotransmitter NO binds to the iron atom in vario.pdf
When acting as a neurotransmitter NO binds to the iron atom in vario.pdf
 
Which of the following are reasons that Drosophila are an ideal exper.pdf
Which of the following are reasons that Drosophila are an ideal exper.pdfWhich of the following are reasons that Drosophila are an ideal exper.pdf
Which of the following are reasons that Drosophila are an ideal exper.pdf
 
What Michael acceptor is needed for the conjugate addition Beta - .pdf
What Michael acceptor is needed for the conjugate addition  Beta - .pdfWhat Michael acceptor is needed for the conjugate addition  Beta - .pdf
What Michael acceptor is needed for the conjugate addition Beta - .pdf
 
What is the role of intuition in decision-makingSolutionIntui.pdf
What is the role of intuition in decision-makingSolutionIntui.pdfWhat is the role of intuition in decision-makingSolutionIntui.pdf
What is the role of intuition in decision-makingSolutionIntui.pdf
 
What is the difference between a HTML element’s id attribute and nam.pdf
What is the difference between a HTML element’s id attribute and nam.pdfWhat is the difference between a HTML element’s id attribute and nam.pdf
What is the difference between a HTML element’s id attribute and nam.pdf
 
What happens when youre Running Scripts without a console in Linux.pdf
What happens when youre Running Scripts without a console in Linux.pdfWhat happens when youre Running Scripts without a console in Linux.pdf
What happens when youre Running Scripts without a console in Linux.pdf
 
TrueFalse A virtual private network is a way to use the Internet to.pdf
TrueFalse  A virtual private network is a way to use the Internet to.pdfTrueFalse  A virtual private network is a way to use the Internet to.pdf
TrueFalse A virtual private network is a way to use the Internet to.pdf
 
The total physical units accounted for is the sum of the units co.pdf
The total physical units accounted for is the sum of the units co.pdfThe total physical units accounted for is the sum of the units co.pdf
The total physical units accounted for is the sum of the units co.pdf
 
The probability that a teacher will give an unannounced test duri.pdf
The probability that a teacher will give an unannounced test duri.pdfThe probability that a teacher will give an unannounced test duri.pdf
The probability that a teacher will give an unannounced test duri.pdf
 
The Orlando MedicalOrlando Medical Corporation financial statements.pdf
The Orlando MedicalOrlando Medical Corporation financial statements.pdfThe Orlando MedicalOrlando Medical Corporation financial statements.pdf
The Orlando MedicalOrlando Medical Corporation financial statements.pdf
 
The IP network is a virtual network and must rely on a link layer ne.pdf
The IP network is a virtual network and must rely on a link layer ne.pdfThe IP network is a virtual network and must rely on a link layer ne.pdf
The IP network is a virtual network and must rely on a link layer ne.pdf
 
Table 1 Endowment of Labor and Capital US 100 20 Canada 10 Workers Ma.pdf
Table 1 Endowment of Labor and Capital US 100 20 Canada 10 Workers Ma.pdfTable 1 Endowment of Labor and Capital US 100 20 Canada 10 Workers Ma.pdf
Table 1 Endowment of Labor and Capital US 100 20 Canada 10 Workers Ma.pdf
 
State if you agree or disagree with the statement made and whyLes.pdf
State if you agree or disagree with the statement made and whyLes.pdfState if you agree or disagree with the statement made and whyLes.pdf
State if you agree or disagree with the statement made and whyLes.pdf
 
subject.....project management.Tools and Processes Based on the pr.pdf
subject.....project management.Tools and Processes Based on the pr.pdfsubject.....project management.Tools and Processes Based on the pr.pdf
subject.....project management.Tools and Processes Based on the pr.pdf
 
Read and discuss the following three articles 1. ACAs Perform.pdf
Read and discuss the following three articles 1. ACAs Perform.pdfRead and discuss the following three articles 1. ACAs Perform.pdf
Read and discuss the following three articles 1. ACAs Perform.pdf
 

Recently uploaded

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Recently uploaded (20)

Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 

The problem can be found below. I would like someone to run this. I .pdf

  • 1. The problem can be found below. I would like someone to run this. I don’t get it because there’s an error. Please, fix this because I don’t know what is happening. What version of python should I use? Please, if you don’t know what is happening let someone else to do it. Bp Project untitled PycharmProjects/untitled 3 import sys ServerPort 80 new server Socket socket (AF INET, S0CK STREAM) Illi External Libraries 6 #Prepare a sever socket 7 #Fill in start server Socket.bind server Port)) server Socket.listen (1) print the web server is up on port server Port 10 #Fill in end 11 while True: Establish the connection 13 print "Ready to serve... 14 connectionSocket add J server Socket. accept() 15 16 try: message connectionSocket.recv(1024) 17 print message message split 01, message. split 1] 18 filename 3 message. split [1] print filename 'II filename [1:] 20 open (filename (1:1) 21 output data f.read 22 print outputdata 23 Send one HTTP header line into socket Fill in start 25 connection Socket.send(' InHTTP/1.1 200 0KNnNn 26 connectionSocket.send(outputdata) 27 Fill in end 28 Send the content of the requested file to the client 29 for i in range (0, len(outputdata)): 30 connection Socket.send(outputdata [i]) 31 connection Socket.close 32 33 except IOError w Send response message for file not found 34 Fill in start 35 connectionSocket.send NnHTTP/1.1 404 Not Found nAn 36 connectionSocket.send 'InHTTP/1.1 404 Not Found n ') 37 38 39 /Library/Frameworks/Python, framework/Versions/2.7/bin/python2.7 /Users. File User S untitled new py", line 33 except IOError: SyntaxError: invalid syntax Process finished with exit code 1 Solution Update your code as below : #!/bin/python import sys import socket serverPort=80 serverSocket = socket.socket(socket.AF_INET,socket.SOCK_STREAM) serverSocket.bind(('',serverPort)) serverSocket.listen(1) while True : connectionSocket, addr = serverSocket.accept() try : message = connectionSocket.recv[1024] filename = message.split()[1]
  • 2. f = open(filename[1:]) outputdata = f.read() connectionSocket.send(' HTTP/1.1 200 OK ') connectionSocket.send(outputdata) for i in range(0,len(outputdata)): connectionSocket.send(outputdata[i]) connectionSocket.close() except IOError : #indentation is not correct here connectionSocket.send(' HTTP/1.1 404 Not Found ') serverSocket.close();