Tom Cocker Communication Contract (Microservice A)
How to programmatically REQUEST data: To request data, in this case, the data is a randomly selected game title, and a “Generate” must be written to the open request text file (Request.txt) to initiate the activation of the microservice. Ex. with open(RequestFile, "w") as file: # Open the request file for writing file.write("Generate")
How to programmatically RECIEVE data:
To receive data, again with the data being a randomly selected game title, the request will be read from the request file (Request.txt) and trigger a random game to be selected. The game selected will be written to an output file (Output.txt) that will then be opened, read, and printed.
Ex.
if os.path.exists(OutputFile): # Check whether the output file is in
with open(OutputFile, "r") as file: # Read the random game
Result = file.read().strip()
if Result:
print("Random Game:", Result)
return
