I'm creating a server-client code in python and I'm trying to send an image file from the server to the client by reading the bytes of the file and sending it. For some reason the bytes that has been read don't represent an appropriate file that can be seen - when I save the bytes I read as an image they don't give the image I scanned theme from.
elif command == COMMANDS[1]:
print(f'Reading the bytes of {params[0]}')
f = open(params[0], 'rb')
data = f.read()
if os.path.exists(r'C:\Users\orlav\Desktop\networking_book_stuff\tech_server\screen2.jpg'):
os.remove(r'C:\Users\orlav\Desktop\networking_book_stuff\tech_server\screen2.jpg')
f2 = open(r'C:\Users\orlav\Desktop\networking_book_stuff\tech_server\screen2.jpg', 'wb+')
f2.write(data)
for some reason f2 doesn't contains what f contains