Giter Club home page Giter Club logo

podcastdownloader's Introduction

Build Status IBM Cloud Deployments

Create a podcast downloader using OpenWhisk

In this Code Pattern, we will a podcast downloader using Microservices and OpenWhisk. [Explain briefly how things work]. [Give acknowledgements to others if necessary]

When the reader has completed this Code Pattern, they will understand how to:

  • compose a microservices style app
  • utilize the power of OpenWhisk

Flow

  1. Step 1.
  2. Step 2.
  3. Step 3.
  4. Step 4.
  5. Step 5.

Included components

  • OpenWhisk: Execute code on demand in a highly scalable, serverless environment.

Featured technologies

  • Microservices: Collection of fine-grained, loosely coupled services using a lightweight protocol to provide building blocks in modern application composition in the cloud.

Watch the Video

Steps

Use the Deploy to IBM Cloud button OR create the services and run locally.

Run locally

  1. Create database
  2. Server side
  3. Create a zip python action
  4. Deploy Downloader action to openwhisk platform as a web action
  5. Invoke downloader action from podcast manager

Prerequisite

Make sure you have a Bluemix account. Suppose you're familiar with Basic OpenWhisk programming Model and idea

Installation requirements:

  • Python2.7 Installed.
  • pip install -r requirements.txt
  • Mysql DB server instance installed locally or provisioned on remote cloud server.
  • curl command tool or similar tools available.

1. Create database

Provision a mysql dabatase instance, use the podcasts_downloader.sql to create the database tables. Use curl to create the users, subscriptions, and podcasts. For example, suppose your podcast manager api server runs locally and listen on port 5000.

  • create a user. curl -X POST "http://localhost:5000/customer?name=liu"
  • create a podcast. curl -X POST "http://localhost:5000/podcast?podname=google&url=https://www.ted.com/talks/rss"
  • create a subscription. curl -X POST "http://localhost:5000/sub?customerid=2&podid=2"

2. Server side

Start the podcasts manager api server.

  • export FLASK_APP=podcasts_manager.py
  • export FLASK_DEBUG=1
  • flask run

3. create a zip python action.

Make sure you have docker installed locally and you have openwhisk/python2action docker images already built successfully.

  • cp DownloaderAction.py __main__.py

Integrate Downloader action with the OpenStack swift client.

In order to persist the downloaded podcast content on storage, now we support integrate with OpenStack swift client, to persist the downloaded content on IBM object storage. First, you need to provision an object storage service, and copy all your storage service authentication information to VCAP_SERVICES.json, the Downloader Action will read the VCAP_SERVICES.json file, to pass the storage services authentication.

Make the zip python aciton.

  • docker run --rm -v "$PWD:/tmp" openwhisk/python2action sh \ -c "cd tmp; virtualenv virtualenv; source virtualenv/bin/activate; pip install -r requirements.txt;"

  • zip -r wgetPython.zip virtualenv __main__.py VCAP_SERVICES.json

4. Deploy Downloader action to openwhisk platform as a web action

wsk action create /[email protected]_dliu/demo/wgetPython --kind python:2 --web true wgetPython.zip

5. Invoke downloader action from podcast manager

curl -X POST -m 50 "http://localhost:5000/download?customername=liu&downloader_url=https://openwhisk.ng.bluemix.net/api/v1/web/[email protected]_dliu/demo/wgetPython"

License

Apache 2.0

podcastdownloader's People

Contributors

mlangbehn avatar loafyloaf avatar

Watchers

James Cloos 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.