-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
52 lines (50 loc) · 1.83 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# make a caller for server or client
import os
from server import Server
from client import Client
from lib import *
if __name__ == '__main__':
while True:
print("1. Server")
print("2. Client")
print("3. Exit")
choice = input("Enter your choice: ")
if choice == '1':
input_file = input("Enter file name: ")
ip = input("Enter ip (default = localhost): ")
port = input("Enter port (default = 8080): ")
# paralel = int(input("Enter paralel: "))
if (not os.path.isfile(input_file)):
print("File not found")
continue
if (input_file == ''):
print("File name cannot be empty")
continue
if (ip == ''):
ip = 'localhost'
if (port == ''):
port = 8080
server = Server(Connection(ip=ip, port=int(port)),file_path=input_file)
server.run()
elif choice == '2':
client_ip = input("Enter client ip (default = localhost): ")
if (client_ip == ''):
client_ip = 'localhost'
client_port = input("Enter client port (default = 6000): ")
if (client_port == ''):
client_port = 6000
ip = input("Enter ip server: ")
if (ip == ''):
ip = 'localhost'
port = input("Enter port: ")
if (port == ''):
port = 8080
folder = input("Enter folder: ")
if (folder == ''):
folder = 'output'
client = Client(Connection(ip=client_ip, port=int(client_port)), server_ip=ip, server_port=int(port), folder_path=folder)
client.run()
elif choice == '3':
break
else:
print("Invalid choice")