Giter Club home page Giter Club logo

caffe2-for-lambda_bmu1's Introduction

serverless-flask

pip package for serverless framework

Compatibility

This is tested with Python3.6 and Serverless Framework

Installation

Command to install

pip install serverless-flask

Usage

Define logger and middleware annotation like below,

you can throw application log (Now logging level is only DEBUG) and add your custom middleware you define.

โ€ป ) There is one thing to note. The order you annote should be app.route, logger and middleware from the top. If you change this order flask throw Exception. (in the future we wanna modify this restriction)

from serverless_flask.interceptor import Interceptor as interceptor

@interceptor.logger
@interceptor.middleware(func1)
@interceptor.middleware(func2)
def test(*args, **kwargs):
    return jsonify({
            "message": "ok"
        })

As you can see in the below code, your custom middleware should have request parameter (but you don't have to use it.).

These functions must return the values with type of dict, list or tuple, otherwise Exception will be thrown.

from flask import request

def func1(req: request):
    return {'key': "value"}

def func2(req: request):
    return ['val1', 'val2'] 

Links

Website: coming soon

Code: https://github.com/Queue-inc/serverless-flask

Company Page: http://www.queue-inc.com

caffe2-for-lambda_bmu1's People

Contributors

shibatanaoto avatar trellixvulnteam avatar

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.