Update server.py
This commit is contained in:
1 parent
b57d50e7b0
commit
6591589b77
1 file changed
+5
-3
+5
-3
@@ -1,5 +1,6 @@
|
||||
# server.py
|
||||
import socket
|
||||
import subprocess
|
||||
|
||||
HOST = "0.0.0.0"
|
||||
PORT = 5000
|
||||
@@ -15,10 +16,11 @@ while True:
|
||||
conn, addr = server_socket.accept()
|
||||
print(f"Connected by {addr}")
|
||||
|
||||
data = conn.recv(1024)
|
||||
print("Received:", data.decode())
|
||||
command = conn.recv(1024)
|
||||
print("Received Grep Command:", command.decode())
|
||||
|
||||
conn.sendall(b"Hello from server!")
|
||||
result = subprocess.run(command.decode(), capture_output=True, text=True)
|
||||
conn.sendall(result.stdout.encode())
|
||||
|
||||
conn.close()
|
||||
|
||||
|
||||
Reference in new issue
Block a user