Update server.py
This commit is contained in:
1 parent
cc539814d8
commit
6088a16f8f
1 file changed
+4
-1
+4
-1
@@ -2,6 +2,7 @@
|
|||||||
import socket
|
import socket
|
||||||
import shlex
|
import shlex
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
HOST = "0.0.0.0"
|
HOST = "0.0.0.0"
|
||||||
PORT = 5055
|
PORT = 5055
|
||||||
@@ -11,6 +12,8 @@ server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|||||||
server_socket.bind((HOST, PORT))
|
server_socket.bind((HOST, PORT))
|
||||||
server_socket.listen()
|
server_socket.listen()
|
||||||
|
|
||||||
|
SCRIPT_DIR = Path(__file__).resolve().parent
|
||||||
|
|
||||||
print(f"Server listening on {HOST}:{PORT}")
|
print(f"Server listening on {HOST}:{PORT}")
|
||||||
|
|
||||||
def send_message(sock, message):
|
def send_message(sock, message):
|
||||||
@@ -56,7 +59,7 @@ while True:
|
|||||||
|
|
||||||
command_args.insert(1, "-n")
|
command_args.insert(1, "-n")
|
||||||
|
|
||||||
result = subprocess.run(command_args, cwd="~/fa26_cs425_.group-mp_.team-01/MP1" capture_output=True, text=True)
|
result = subprocess.run(command_args, cwd=SCRIPT_DIR, capture_output=True, text=True)
|
||||||
|
|
||||||
send_message(conn, result.stdout + result.stderr)
|
send_message(conn, result.stdout + result.stderr)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user