Hopefully I can make this somewhat clear. I have to create a server and client in python that sends HTTP GET request to each other. Now I created a basic server/client program and now my goal is to send the server a HTTP GET request(from an html file I have saved) and the server to display the content. Example Server would display something like Date: Content Length: content Type: As of now when I run the client and type GET / filename.html HTTP/1.1\n\r the server does not display. When I type that exact command in just a Linux shell it displays perfectly. How can I do this in a client and server. Hopefully this makes sense. Here is my client and server.
#CLIENT
import socket
import sys
host = socket.gethostname()
port = 12345 # The same port as used by the server
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
print(s.recv(1024))
inpt = input("type")
b = bytes(inpt, 'utf-8') #THIS SENDS BUT SERVER DOESDNT RECIEVE
s.sendall(b)
print("Message Sent")
#SERVERimport socket
import sys
host = '' # Symbolic name meaning all available interfaces
port = 12345 # Arbitrary non-privileged port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((host, port))
s.listen(5)
while True:
c, addr = s.accept()
print("Connection accepted from " + repr(addr[1]))
c.send(b"Server Approved")
print(repr(addr[1]) + ":" + c.recv(1024).decode("UTF-8"))
c.close()
I want to type something like this to my server and display its content
GET / google.com HTTP/1.1\r\n