Implementing the notification service
Now that we have everything set up, and the files that we are going to use as a template to send emails to the customers of the online (video) game store are in place in the python-blueprints S3 bucket, it is time to start implementing the notification service.
Let's go ahead and create a file called app.py
in the notifier
directory, and to start with, let's add some imports:
import smtplib from http import HTTPStatus from smtplib import SMTPAuthenticationError, SMTPRecipientsRefused from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart import boto3 from botocore.exceptions import ClientError from flask import Flask from flask import request, Response from jinja2 import Template import json
First, we import the JSON module so we can serialize and deserialize data. We import HTTPStatus
from the HTTP module so we can use the HTTP status constants when sending responses back from the service's endpoints.
Then we import the...