Code Monkey home page Code Monkey logo

flask-lambda2's Introduction

Flask-Lambda2

Flask-Lambda2 is a python package to add a compatibility layer between a Flask application and AWS Lambda for creating RESTful applications.

https://pepy.tech/badge/flask-lambda2

This package is opinionated, in that "it locks or guides you into [our] way of doing things" or "doesn't make it easy to diverse from [our] golden path."

Installation

$ pip install flask-lambda2

Requirements

The main assumption here is that your project can comfortably and reasonably fit into a single endpoint, or you separate your Lambda functions to group certain, related API endpoints together.

Firstly, ensure your Lambda handler is set to project_api.app, where project_api is the filename (excluding the .py extension) containing your project's API endpoint implementations and where app is the Flask instance (actually a FlaskLambda instance) with which you have added the URL rules onto.

Lastly, ensure that invokation convention from the location you plan to invoke the endpoints from roughly follows the calling convention shown below:

import boto3


client = boto3.client('lambda')
client.invoke(FunctionName='project_api',
              InvocationType='RequestResponse',
              Payload=json.dumps({'route':'/users/',
                                  'method':'get',
                                  'token':'123abc'}))

That's it!

Tests

Tests are available in Flask-Lambda2/tests through invoking test.py with python test.py. Ensure all dependencies are installed through invoking pip install -r requirements.txt.

Functional Examples

GridLight-API

I have created a backend for a mobile application using this library, it's source code is available here at the GridLight-API repository.

If you have any questions, feel free to e-mail me at [email protected].

Built With

  • Flask - Micro web-framework based on Werkzeug and Jinja2

License

This project is licensed under the Apache 2.0 License - see the LICENSE.md file for details

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.