Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- this program connects to sockets in a server and receives requests, reading in if it is a GET or PUT.
- If it is not it breaks. If you send a GET it will grab the file name and check for that file, if that file
- exists, it will parse the contents and send them. If it is a PUT, it receives content and saves it into a
- file. The Client will check if there are enough args, if not, it will tell the user they need more in their
- input, if it is enough, they will then parse those args and save them as variables. It will use these variables
- to grab all the necessary information and see what kind of request it is. If it's a GET, it grabs the required
- filename, and attempts a GET to the server. If it is a PUT, it parses a file by that name, and sends the results to
- the server. If the file doesn't exist, it lets the user know this.
- Some testing:
- working GET:
- ➜ alex python client.py localhost 8888 GET sent.txt
- 200 ok test
- ('Received', "'200 ok test'")
- wrong filename GET:
- ➜ alex python client.py localhost 8888 GET doesnt_exist.txt
- 404 not found
- ('Received', "'404 not found'")
- working put:
- ➜ alex python client.py localhost 8888 PUT sent.txt
- success
- wrong filename put:
- ➜ alex python client.py localhost 8888 PUT doesnt_exist.txt
- no such file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement