Anja Freudenreich f077ffdf3c initial commit
2024-03-27 13:31:27 +01:00

28 lines
737 B
Python

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)