-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
40 lines (34 loc) · 1.16 KB
/
client.py
File metadata and controls
40 lines (34 loc) · 1.16 KB
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
import zmq
def main():
context = zmq.Context()
socket = context.socket(zmq.REQ)
socket.connect("tcp://localhost:5555")
while True:
print("1. View Recipes")
print("2. Save Recipe")
print("3. Remove Recipe")
print("4. Exit")
choice = input("Enter your choice: ")
if choice == "1":
socket.send_string("VIEW")
recipes = socket.recv_string()
print("-------------------------------------")
print("Recipes:")
print(recipes)
print("-------------------------------------")
elif choice == "2":
recipe = input("Enter recipe to save: ")
socket.send_string(f"SAVE {recipe}")
response = socket.recv_string()
print(response)
elif choice == "3":
recipe = input("Enter recipe to remove: ")
socket.send_string(f"REMOVE {recipe}")
response = socket.recv_string()
print(response)
elif choice == "4":
break
else:
print("Invalid choice.")
if __name__ == "__main__":
main()