This microservice will receive a message via text file, process it, and write the results to a log file. Start the microservice so that it is running in the background.
How to send a request: Write a message in the request.txt file for the microservice to read.
with open(REQUEST_FILE, "r") as f:
message = f.read().strip()
How to receive the results: Results can be read directly from the notification_log.txt file.
def log_message(status, message):
with open(LOG_FILE, "a") as log:
log.write(f"{time.strftime('%Y-%m-%d %H:%M:%S')} - {status}: {message}\n")