-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
30 lines (22 loc) · 767 Bytes
/
client.py
File metadata and controls
30 lines (22 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import socket
name=input('enter the name:')
#address=input('enter your address:')
#root_address=address+'/'+name+'.html'
HOST = '127.0.0.1' # The server's hostname or IP address
PORT = 65435 # The port used by the server
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((HOST, PORT))
s.sendall(name.encode())
respons = s.recv(1024)
if(respons.decode()=='200'):
while True:
data=s.recv(1024)
if not data:
break
with open(name+'.html','wb') as content:
content.write(data)
print('File downloaded.')
break
else:
print("404NOTFOUNDED")
#print('Received', repr(data))