Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Python + Flask Web Action Proxy Example

This example demonstrates how to run an existing Python web application (built using Flask) on Apache OpenWhisk with the Web Action Proxy.

These steps can be used to wrap other Python web applications.

example application

This is the example application that will be wrapped into a Docker image with the Web Action Proxy.

Flask Example

The web application renders static HTML content for home page and a JSON API at the /data route.


clone project repo and install modules

modify the app source code

Due to the limitations of the Web Action Proxy, the XHR URL for the backend must refer to relative locations, rather than /data.

  • Replace URL path in template/index.html
-        d3.json("/data", callback);
+        d3.json("data", callback);
  • Change to make it suitable for the platform.
-import json
+from flask import jsonify

-    return json.dumps([{"_id": i, "x": x[i], "y": y[i], "area": A[i],
+    return jsonify([{"_id": i, "x": x[i], "y": y[i], "area": A[i],

-    os.system("open http://localhost:{0}".format(port))

-    app.debug = True

create docker build file assets

  • Create a Dockerfile in the parent directory to the flask-d3-hello-world with the following contents.
FROM node:10

ADD flask-d3-hello-world /app/
ADD /app/
ADD proxy /app/

RUN curl -o
RUN python3
RUN pip install numpy flask


CMD ./
  • Copy the proxy binary from the Web Action Proxy repo to the parent directory of flask-d3-hello-world.

  • Create a file in the parent directory to the flask-d3-hello-world with the following contents.


./proxy & python3

docker build, tag and push!

  • Build the Docker image for the example application.
 docker build -t flask .
  • Tag the local image with the Docker Hub repo name.
 docker tag flask <USERNAME>/flask
  • Push the local image to Docker Hub.
 docker push <USERNAME>/flask

create web action

  • Create the Apache OpenWhisk Web Action from the public Docker image.
wsk action create flask --docker <USERNAME>/flask --web true

access web application

  • Retrieve the Web Action URL for the expressjs action.
 wsk action get flask --url
  • Open the Web Action URL (with a / appended to the action name) in a web browser, i.e.

Important: Page links won't work unless the Web Action URL ends with a / after the action name.

Flask Example

You can’t perform that action at this time.