code for article pfeilbr/serverless-flask-playground
Example of running python Flask app on Lambda + API Gateway via serverless framework. Based on Build a Python REST API with Serverless, Lambda, and DynamoDB.
Architecture
Prerequisites
- serverless framework
- Docker Desktop
- Python 3.8
- pipenv
Running
# ensure python venv loaded in shell
pipenv shell
# install npm deps for serverless
npm install
# run flash app locally. server reloads on file change. still need to refresh page in browser
npm run dev
# deploy. (docker must be running to build python packages for linux target / lambda)
npm run deploy
Twitter • Reddit