Skip to Content
Flask Framework Cookbook - Second Edition
book

Flask Framework Cookbook - Second Edition

by Shalabh Aggarwal
July 2019
Beginner to intermediate
302 pages
9h 38m
English
Packt Publishing
Content preview from Flask Framework Cookbook - Second Edition

How to do it...

Now, make some changes to our existing catalog application to accommodate support for file upload and retrieval from S3:

  1. First, we need to store the AWS-specific configuration to allow boto to make calls to S3. Add the following statements to the application's configuration file, that is, my_app/__init__.py:
app.config['AWS_ACCESS_KEY'] = 'Amazon Access Key' 
app.config['AWS_SECRET_KEY'] = 'Amazon Secret Key' 
app.config['AWS_BUCKET'] = 'Your S3 Bucket Name' 
  1. Next, we need to change our views.py file:
from boto3 

This is the import that we need from boto. Next, we need to replace the following line in create_product():

image.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) 

This will be replaced with the following ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Writing a Web Application with Flask

Writing a Web Application with Flask

Doug Farrell
Mastering Flask

Mastering Flask

Jack Stouffer

Publisher Resources

ISBN: 9781789951295Supplemental Content