Best Flask open-source libraries and packages

Api serverless flask

This a sample repo for a serverless API made with flask and SQLAlchemy which can be deployed to AWS API Gateway + AWS Lambda + AWS Aurora
Updated 2 years ago

DevOps Test

This an API example.

Technologies involved

This code is based on python-serverless-api. Technologies involved are:

This code can be deployed to AWS easily by using terraform The service is deployed in

You can test the live version deployed with Swagger Editor.

Infrastructure

This deployment uses:

  • AWS API Gateway
  • AWS Lambda
  • AWS Aurora PostgreSQL Serverless

alt text

Setup

1. Create .env file and update contents

This is used to set the environment variables required for deployment and local development.

$ cp .env.example .env
$ vim .env

2. Create a virtualenv then install requirements:

$ make env
$ source env/bin/activate
$ make deps

Example Usage

1. Set Environment

Ensure you have created your virtualenv and have the necessary environment variables set (see setup instructions above).

$ source env/bin/activate
$ source .env

2. Run server

On host
$ make server
In docker
$ docker-compose up

3. Manually test development server

$ http-prompt localhost:5000
GET /hello/whatever

Run tests

Run the following command:

make test
make lint

Deploy to AWS

1. Set AWS credentials

Export AWS_ACCESS_KEY_ID, AWS_DEFAULT_REGION and AWS_SECRET_ACCESS_KEY variables.

2. Create tfstate bucket

cd terraform/init
terraform init
terraform apply

3. Generate bundle and deploy

Then run the following command:

./bin/deploy