123456789101112131415161718192021222324252627 |
- import requests
- import json
-
- # Define the server adress and port
- #SERVER_ADDR = "http://172.18.0.2"
- #SERVER_ADDR = "http://127.0.0.1"
- #SERVER_ADDR = "host.docker.internal"
- SERVER_ADDR = "http://fizzbuzz_server"
- SERVER_PORT =8080
-
- # Define the URL for the FizzBuzz endpoint
- URL = f"{SERVER_ADDR}:{SERVER_PORT}/fizzbuzz"
-
- try:
- for number in range(1,101):
- # Define the payload data (JSON format)
- payload = {'number': number}
-
- # Send the HTTP POST request with JSON payload
- response = requests.post(URL, json=payload)
-
- # Print the response
- print(f"Number: {number}, Response: {response.text}")
-
- except requests.RequestException as e:
- # Handle request exceptions
- print("Error:", e)
|