Book Image

Building Serverless Python Web Services with Zappa

By : Abdulwahid Abdulhaque Barguzar
Book Image

Building Serverless Python Web Services with Zappa

By: Abdulwahid Abdulhaque Barguzar

Overview of this book

Serverless applications are becoming very popular these days, not just because they save developers the trouble of managing the servers, but also because they provide several other benefits such as cutting heavy costs and improving the overall performance of the application. This book will help you build serverless applications in a quick and efficient way. We begin with an introduction to AWS and the API gateway, the environment for serverless development, and Zappa. We then look at building, testing, and deploying apps in AWS with three different frameworks--Flask, Django, and Pyramid. Setting up a custom domain along with SSL certificates and configuring them with Zappa is also covered. A few advanced Zappa settings are also covered along with securing Zappa with AWS VPC. By the end of the book you will have mastered using three frameworks to build robust and cost-efficient serverless apps in Python.
Table of Contents (20 chapters)
Title Page
Dedication
Packt Upsell
Contributors
Preface
Index

Installing and configuring Flask


We are going to develop a Flask-based REST API that will be deployed as serverless on AWS Lambda. So, here, installing and configuring Flask would be in a virtual environment. 

We are going to be creating a virtual environment and enabling it to install all the required packages. This can be done using the following command:

virtualenv .env -p python3.6
source .env/bin/activate

Now, we are going to list all of the required packages in the requirements.txt file and we will install all of the packages at once. The following describes the content of the requirements.txt file:

Flask==0.12.2
Flask-JWT==0.3.2
Flask-SQLAlchemy==2.3.2
Flask-Migrate==2.1.1
flask-restful==0.3.6
zappa==0.45.1

Now, we can install all of these packages using the following command:

$ pip install -r requirements.txt

That's all of packages that will be installed in the virtual environment. Now, let's have a detailed explanation of these packages in the next section.

Flask extensions

Flask has a...