Dateien für die Aufgabe 2.4: Netzwerke und Kommunikation zwischen Containern
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

player.py 737B

123456789101112131415161718192021222324252627
  1. import requests
  2. import json
  3. # Define the server adress and port
  4. #SERVER_ADDR = "http://172.18.0.2"
  5. #SERVER_ADDR = "http://127.0.0.1"
  6. #SERVER_ADDR = "host.docker.internal"
  7. SERVER_ADDR = "http://fizzbuzz_server"
  8. SERVER_PORT =8080
  9. # Define the URL for the FizzBuzz endpoint
  10. URL = f"{SERVER_ADDR}:{SERVER_PORT}/fizzbuzz"
  11. try:
  12. for number in range(1,101):
  13. # Define the payload data (JSON format)
  14. payload = {'number': number}
  15. # Send the HTTP POST request with JSON payload
  16. response = requests.post(URL, json=payload)
  17. # Print the response
  18. print(f"Number: {number}, Response: {response.text}")
  19. except requests.RequestException as e:
  20. # Handle request exceptions
  21. print("Error:", e)