0
Python side server(socket)
i trying to write server using python. but the server is sending multiple files like index.html and index.css. so in server.py its send 2 files. but something strange is, the index.css is merged with index.html. here the script: https://code.sololearn.com/WNNnCoLbqWy2/?ref=app https://code.sololearn.com/WTp99Y5GsxgC/?ref=app https://code.sololearn.com/cpJ3D77gI8E1/?ref=app https://code.sololearn.com/c5g32wOCSAG2/?ref=app i try open index.html(offline) and work well, how to fix it?
5 Antworten
+ 2
https://code.sololearn.com/cPf24s8G5aA5/?ref=app
works. thanks for the hint
+ 1
On line 19 and 20 of your server you send the contents of index.html and index.css back to back. In normal Web server and client communication each page is supposed to be a separate request to the server and therefore a different socket.
+ 1
thanx for the answer, i will try to experiment. i will tell you my result
+ 1
The way you have written the client_handler function it will send both file with any request. You need to write it in such a way that your client program will ask for index.html once, then it should ask again in a separate request for index.css
The separate request will be the new socket. What you need to do is figure out what file is being requested in each request. Then have the thread kick off a dynamic client_handler that will only read in the requested file.
0
im confuse, what diffrent socket? i add some thread again so it will send file, close connection and repeat again. not working. error bad file descriptor. help me please