Git Product home page Git Product logo

bstpy's Introduction

bstpy

Python AWS Lambda Server

Recommended Uses

Use bstpy to expose an AWS Lambda as an http endpoint locally. It provides a Python "harness" that you can use to wrap your function and run/analyze it.

  • Development

    • Run your lambda functions instantly locally, without packaging and sending to AWS.
    • Shorten your feedback loop on lambda executions.
  • Testing

    • Use it with other bespoken tools, like the bst Alexa emulator or bst proxy, to instantly test your Alexa skill.

Features

Present:

  • Run an AWS-compatible lambda function as an http endpoint.
  • Automatically reloads your skill so you can see your changes without restarting it.

Planned:

  • accessing AWS resources
  • picking up any libraries present in ./lib directory of the project
  • context from file

Installation

  1. git clone the bstpy repo
  2. Install it with pip install -e bstpy (you might need to sudo this command if you're using your system Python instead of a virtualenv or similar)

Usage

$ bstpy --help
Usage: bstpy <lambda-path> -p <port> -t <timezone>

The only mandatory paramater is the first parameter, the lambda path.

Use -p (--port) to listen on another port.

Use -t (--timezone) to specify the timezone you want to run on. The default is UTC.

$ bstpy foo -t US/Eastern

Yo can also use -h (--help) for help and -v (--version) for version.

Quick Start

Try the example lambda in the project

From the example folder, run: bstpy TestSkill.example_handler

You should see output similar to the following:

Lambda path: foo
Current time is 14:04:42 10/17/16 UTC
Starting httpd on port 10000

Note: This is the simplest way to call a handler in a Python file. Alternatively you can specify a module and a function like this: Module1[.Module2][.Module3].handler_function, just make sure the module is seen from your Python path. The script will add your current folder (.) to the path (your welcome).

From another terminal window in the project root folder, run: ./test.sh

Note: You need to have curl installed for this. Of course you can use your own favorites, like Postman.

What's happening?

In this example, bstpy:

  1. Loads the example_handler function from the TestSkill module (file in this case).
  2. Starts a simple http server on port 10000 and starts listening for POST request with json bodies (events)
  3. Curl will post the content of the event.json file
  4. LambdaServer calls the the lambda handler
  5. Returns the resulting json

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.