-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
44 lines (35 loc) · 1.22 KB
/
Copy pathclient.py
File metadata and controls
44 lines (35 loc) · 1.22 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
41
42
43
44
import zmq
# Setting up the ZeroMQ client
context = zmq.Context()
socket = context.socket(zmq.REQ)
socket.connect("tcp://localhost:5555")
def main():
while True:
print("\nChoose an option:")
print("H: Calculate heart rate intensity")
print("T: Get information on how to check your heart rate")
print("C: Calculate target heart rate")
print("Q: Quit")
option = input("Enter your choice (H/T/C/Q): ").strip().upper()
if option == "H":
age = input("Enter your age: ")
heart_rate = input("Enter your heart rate: ")
request = f"H {age} {heart_rate}"
elif option == "C":
age = input("Enter your age: ")
request = f"C {age} xxx"
elif option == "T":
request = "T xxx xxx"
elif option == "Q":
print("Exiting the program.")
break # Exit the loop and program
else:
print("Invalid option.")
continue # Go back to the menu
# Send request to the server
socket.send_string(request)
# Get the response from the server
message = socket.recv_string()
print(f" {message}")
if __name__ == "__main__":
main()