Skip to content
Serverless Template for a Flask application
Branch: master
Clone or download
Pull request Compare This branch is 16 commits ahead of alexdebrie:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
api throw in openapi client codegen for good measure Nov 10, 2018
.gitignore
LICENSE
Makefile
README.md
app.py
package.json
postsetup.js
requirements.txt
serverless.yml
tox.ini

README.md

Serverless-Flask

API edition.

The fastest way to a Flask application with Serverless.

This version includes APISpec and Marshmallow for easy declaration of input and output for API functions and automatic generation of swagger. CORS is enabled and can be customized.

Usage

yarn global install serverless
sls install --url https://github.com/revmischa/serverless-flask --name my-flask-app
cd my-flask-app
yarn setup
# <answer prompts>
sls deploy

Once the deploy is complete, run sls info to get the endpoint:

$ sls info
Service Information
<snip>
endpoints:
  ANY - https://abc6defghi.execute-api.eu-central-1.amazonaws.com/dev <-- Endpoint
  ANY - https://abc6defghi.execute-api.eu-central-1.amazonaws.com/dev/{proxy+}

Copy paste into your browser, and voila!

Local development

To develop locally, create a virtual environment and install your dependencies:

virtualenv venv
source venv/bin/activate
pip install -r requirements.txt

Then, run your app:

sls wsgi serve
 * Running on http://localhost:5000/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!

Navigate to localhost:5000 to see swagger UI for your API.

Client CodeGen

Want to generate a client library for your API? No problem.

  • Run make generate-client lang=$LANG

Where $LANG can be any language supported by OpenAPI-Generator.

e.g. lang=go or lang=typescript-axios.

Configuration

The postsetup.js prompt will walk you through some setup questions that may be custom to your use case. This includes:

You can’t perform that action at this time.