Sunday, February 20, 2011
Simple Multithreaded Web Server in Python
Like before when a client connects its socket it passed to the clientThread Class and then we call start which starts the thread
in the main loop of the thread instead of trying to pinpoint where the GET or POST request is i simply split the string by a space and then get the 2nd element(in this case its the 1st since we start at 0) is the file the client wants
so we take this file and get the extension of the file by spiting the file by the "." so that the 2nd elements(again starting at 0) so that we get the ext of the file requested now we can do a small check and see if they want a plain text/css/javascript file or a exe or image or anything else that would need to be opened with the binary mode right after that we close the socket and stop the while loop
so the client knows we are done sending the requested file.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment