Server/socket_client.py
2024-04-15 21:55:09 +03:00

14 lines
377 B
Python

import socket
HOST = 'localhost'
PORT = 8080
def http_client():
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as client:
client.connect((HOST, PORT))
client.sendall(b'GET / HTTP/1.1\r\nHost: localhost\r\n\r\n')
response = client.recv(1024)
print('Response:', response.decode('utf-8'))
if __name__ == '__main__':
http_client()