14 lines
377 B
Python
14 lines
377 B
Python
import socket
|
|
|
|
HOST = 'localhost'
|
|
PORT = 8081
|
|
|
|
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() |