This project is a simple implementation of a client-server model using Python's socket module. The server is able to handle multiple clients at once.
- Persistent connection is made between server and each client
- Each connection runs on a separate thread.
- Each connection has a dynamic timeout set by server,
timeout = max(5 seconds, 20 - current-number-of-connections) - Server itself has
a timeout of 60 seconds of inactivity, meaning if server doesb't get any requests for continuous 60 seconds it will shut down
Clients can send:
GETrequests to get a certain file from the serverPOSTrequests to send a file to the server
The server can respond with:
200 OKif the request was successful404 Not Foundif the requested file was not found
For GET requests, the server will send the file requested by the client. For POST requests, the server will save the file sent by the client.
The server can handle the following file types:
.txt.jpg.png.html
- Default port: 8080
python3 server/server.py - Commandline argument port
python3 server/server.py 8089
- Client which asks for request every time
python3 client/client.py - Client which parses file to send requests to server
Or use defaults, localhost and 8080:
python3 client/client_parser.py hostname portpython3 client/client_parser.py
- Bonus Test Cases
http://localhost:8080/server/testServer.txthttp://localhost:8080/server/photoServer.jpghttp://localhost:8080/server/welcome.html client.pytestsGET server/testServer.txtPOST client/testClient.txtGET server/photoServer.jpgPOST client/photoClient.jpgGET server/welcome.html
index.html was changed because browsers load its favicon by default which leads to delay, so it was changed to welcome.html to avoid confusion.
