Skip to content

Latest commit

 

History

History
77 lines (57 loc) · 1.91 KB

README.md

File metadata and controls

77 lines (57 loc) · 1.91 KB

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
> [ ]