python/cross_service/photo_analyzer/README.md
Shows you how to use the AWS SDK for Python (Boto3) to create a web application that lets you do the following:
This example contains two main components: a webpage written in JavaScript that is built with React, and a REST service written in Python that is built with Flask-RESTful.
You can use the React webpage to:
The webpage calls the REST service. The service sends requests to AWS to perform the following actions:
The requirements for the webpage are listed in the accompanying package.json file.
You will need recent versions of Node.js and npm to install the requirements.
Install the webpage requirements by running the following in the frontend folder
at a command prompt:
npm install
This installs components like React, React-Bootstrap, and jQuery.
The requirements for the REST service are listed in the accompanying requirements.txt
file. You will need recent versions of Python and pip to the install the requirements.
Install the REST service components by running the following in the api folder in
a virtual environment:
python -m pip install -r requirements.txt
This installs components like Boto3, Flask, and Flask-RESTful.
The example requires an S3 bucket to store photos. You can create an S3 bucket by using the AWS Management Console.
After you create your bucket, update the BUCKET_NAME field in api\config.py with
the name of your bucket.
The example sends an email report by using Amazon SES. When your account is in the sandbox, you must register both the sender and recipient email addresses. You can do this by using the console.
Tip: For this example, you can register the same email account as both the sender and the recipient.
Start the REST service by running the following at a command prompt in the api folder:
python app.py
This starts the Flask web server in debug mode on http://localhost:5000.
Start the webpage in development mode by running the following at a command prompt
in the frontend folder:
npm start
This compiles the project and browses to it at http://localhost:3000.
By default, the application shows that your bucket contains no images.
Select Browse, choose a JPG or PNG file, and select Upload to upload it to your S3 bucket.
Select the image in the list to display it along with labels detected by Amazon Rekognition. When a label includes bounding boxes, it is added to a list of clickable items. Select one to draw boxes over the image.
Select Analyze all photos in your bucket and send a report to use Amazon Rekognition to analyze all photos in your bucket and display a report.
Fill out the form with sender address, recipient address, and a message. Select Send report to email the report.
To avoid charges, use the console to delete all the resources that you created for this tutorial.
Congratulations! You have built a web application that uploads and lists photos in an S3 bucket, uses Amazon Rekognition to analyze photos, and uses Amazon SES to send email to a registered user.
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0