Giter VIP home page Giter VIP logo

flask-openwhisk's Introduction

flask-openwhisk

An experimental integration of Flask on OpenWhisk

How to Use

Currently there is a single function called invoke that will translate a raw HTTP request from OpenWhisk into a WSGI/Flask request and then back into an OpenWhisk response.

You just need to create the main program (__main__.py) that looks like the following:

from flaskwsk.handle import invoke
from web import app

def main(args):
   return invoke(app,args)

In the above app is the Flask application object.

To package you need to include in the zip file:

  1. The virtualenv with all the packaged you Use
  2. The invocation including the __main__.py file

Then you create a raw HTTP action:

wsk action create myapp --kind python:3 myapp.zip --web raw

An Example

The makefile will package a deploy an example application that just echoes a request:

To build and deploy:

make setup
make
make create

To test:

export OPENWHISK=https://...
curl  -v -X PUT -d "test" -H "Content-Type: text/plain" $OPENWHISK/flask/echo

or:

make test OPENWHISK=https://...

where OPENWHISK is your server URL (e.g., https://openwhisk.ng.bluemix.net/api/v1/web/...)

and you should see output like:

{
  "headers": {
    "Accept": "*/*",
    "Cache-Control": "no-transform",
    "Connection": "close",
    "Host": "...",
    "User-Agent": "curl/7.53.1",
    ...
  }, 
  "method": "GET"
}

flask-openwhisk's People

Contributors

alexmilowski avatar alvarolopez avatar

Stargazers

 avatar

Watchers

 avatar  avatar  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.