Untitled
unknown
python
2 years ago
896 B
3
Indexable
import http.client import sys def send_request(connection, message): connection.request('POST', '/', message.encode()) response = connection.getresponse() return response.read().decode() if __name__ == '__main__': try: host_ip = sys.argv[1] host_port = int(sys.argv[2]) # Create an HTTP connection to the server connection = http.client.HTTPConnection(host_ip, host_port) while True: reply = input('Enter reply (exit to quit): ') if reply == 'exit': break # Send reply to server and get response response = send_request(connection, reply) print(response) connection.close() except IndexError: print('[-] Command line argument(s) missing. Please try again.') except Exception as e: print(e)
Editor is loading...