Skip to content

Simple fully managed API server using API Gateway, Lambda, DynamoDB and Flask. And deploy the infrastructure by serverless framework. (API Gateway <-> Lambda (Flask API Server) <-> DynamoDB)

License

Notifications You must be signed in to change notification settings

nipe0324/serverless-flask-sample

Repository files navigation

Serverless Flask Sample

Simple fully managed API server using API Gateway, Lambda, DynamoDB and Flask. And deploy the infrastructure by serverless framework.

Tools & Packages

Prerequisite

  • node.js (npm) greater than or equal to v4
  • aws account
  • awscli

Setup & Deploy

# Download source
git clone [email protected]:nipe0324/serverless-flask-sample.git
cd serverless-flask-sample

# Install serverless globally
npm install serverless -g

# Deploy to aws
serverless deploy -v

# Remove deplyed resources
serverless remove

Samples

export SLS_ENDPOINT=https://m56ha23xqf.execute-api.ap-northeast-1.amazonaws.com/dev

# get all todo list
curl ${SLS_ENDPOINT}/todos
> [ ]

# get a todo
curl ${SLS_ENDPOINT}/todos/1
> {"error":"Not found"}

# create a todo
curl ${SLS_ENDPOINT}/todos -X POST -H "Content-Type: application/json" -d '{"title": "Shopping"}'
> {"id":"1","title":"Shopping"}

# get a todo again
curl ${SLS_ENDPOINT}/todos/1
> {"id":"1","title":"Shopping"}

# update a todo
curl ${SLS_ENDPOINT}/todos/1 -X PUT -H "Content-Type: application/json" -d '{"title": "Shopping 2"}'
> {"id":"1","title":"Shopping 2"}

# get all todo list
curl ${SLS_ENDPOINT}/todos
> [{"id":"1","title":"Shopping 2"}]

# remove a todo
curl ${SLS_ENDPOINT}/todos/1 -X DELETE -H "Content-Type: application/json"
> {"success":true}

# get all todo list
curl ${SLS_ENDPOINT}/todos
> [ ]

About

Simple fully managed API server using API Gateway, Lambda, DynamoDB and Flask. And deploy the infrastructure by serverless framework. (API Gateway <-> Lambda (Flask API Server) <-> DynamoDB)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages