Getting Started with Python Eve on IBM Bluemix™

Share: Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on RedditEmail this to someonePrint this page
pythoneve

BluemixRox

Here’s the latest post in my “BluemixRox” series on deploying popular open-source projects onto Bluemix. In past posts, I’ve shared how to deploy Drupal, WordPress, Ghost.js and Piwik. I’ve now turned my focus to Eve, a Python-based open source web REST API framework for human beings. From the project website, “It allows to effortlessly build and deploy highly customizable, fully featured RESTful Web Services. Eve is powered by Flask, Redis, Cerberus, Events and offers support for both MongoDB and SQL backends [*]”.  This article is NOT about educating you on REST nor convincing you about the benefits of RESTful Web Services.  There are a ton of existing resources already out on the web if that suits your fancy.  Rather, this article assumes you WANT some RESTful Web Services and is meant to get you going fast using this open-source framework that I’ve personally found very quick to deploy (using Bluemix), super easy to configure, extremely flexible in shaping data models and customizing event hooks, all while having a stable active code base with great Stack Overflow support. If you’re still reading and would like to setup your own Python instance on IBM Bluemix, read-on:

TL;DR

Deploy to Bluemix

Sample Github Repository URL: https://github.com/ibmjstart/bluemix-python-eve-sample

Live Web Service Site:  http://macreduce.mybluemix.net/api/v1/mac

Plan of Attack

  1. We’ll deploy a Sample Python Eve (Flask Based) application onto Bluemix.
  2. We’ll populate this application with data from a 3rd party public source
  3. We’ll explore some sample API queries using filters.

Why Python Eve?

  • In the words of the project author, Nicola Iarocci, “you get a lot of features that just work out of the box, which I believe makes it ideal for quick prototyping and PoCs. You can be up and running real quick, and change your API schema/behaviour [fast]”
  • API servers are useful for lots of things: As backends for your next awesome mobile iOS or Android app, as a convenience server to provide CRUD functionality or data aggregation from 3rd party platforms, as a test data stub while you build your next cool solution, …

Let’s get going already …

  1.    Deploy to Bluemix
    Click the button above. Deploying this w/ dependent services onto Bluemix will take < 10 mins. Whew!  That was hard, wasn’t it?  Step 1 Done.
  2. curl -u bluemix:devfun http://{your_bluemixhost}.mybluemix.net/populate

    This endpoint triggers a call to fetch an IEEE MA-L Public Listing for MAC Addresses. Rather than setup an empty RESTful Web Service (What fun is that?), I decided to customize this Python Eve sample with an endpoint that will populate itself with MAC Address 3 Octet Data from a public source.  This enables our server to now be a super-awesome organizational lookup for client MAC addresses.  For example, this might be useful for analyzing a bunch of MAC address data if you want to figure out how much Apple vs. non-Apple access is happening on a router.  Or maybe you need to analyze a bunch of Internet of Things solution logs.  Any hoot, a web service with data is better than one without … for purposes of learning 😉 Step 2 Done.
  3. Let’s try to answer some questions:
    • Q: What are all of the MAC Address Octets associated with IBM?
    • Q: Who is the organization associated with [00:00:18] leading octets?

    Cool.  In less than 15 minutes, we have a personal resource for answering some questions.  Hopefully that scratches the surface of what you can do with a web service full of IEEE MAC Address data that only a networking geek could appreciate.

Food for Thought

Hopefully, this simple approach to getting started with Python Eve has inspired you to consider it for your next project.  Their project website is rich in detail, examples and elaboration about its feature set.  The quality of open source software available for devs coupled with the power of Digital Innovation platforms such as Bluemix … really makes innovation easy and accessible to all.

As homework, for you dear esteemed reader, I would suggest trying to expand the data schema to accommodate address information.  The sample repo currently ignores that data from the IEEE text file and simply persists the organization associated with the MAC Address octet.   Another angle might be to attach other services such as Twilio SMS to your Python Eve app and then create event hooks to alert you whenever your server triggers another data repopulation.  Yet another idea is to hook up the Watson Machine Translation service to your app and create event hooks that perform “on the fly” data translation of your REST resources dependent on what “Accept-Language” header was provided in a request.

Happy Coding!

Share: Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on RedditEmail this to someonePrint this page
Sanjay Joshi
Early in my career, specialized in melting plastic and debating with ISO auditors. Later, tested software test tools - envision a person measuring rulers in a ruler factory. After a promotion, I managed a team great at breaking software. I was also the test organization's performance expert, assessing application throughput/speed and recommending fixes to make applications go faster. Later on, I worked on gluing non-IBM and IBM software together and showing customers how easy it was to do. As a facilitator to support the CEO's office, I organized studies for our executive leadership by gathering people and steering chats to look at disruptive technologies and see where new money could be made. I'm currently a member of the amazing IBM jStart team. We explore the "art of the possible", have an aversion for saying "it can't be done" and love learning through direct client engagement. My general focus has been on cloud-related emerging technologies facilitated by our Cloud Foundry based Platform as a Service (PaaS) - IBM Bluemix™ Within that framework, my current technology adventure is with Apache Spark, lightning fast cluster computing, for Big Data analytics. I've travelled the world and enjoy experiencing new ideas. Curiosity keeps me creating and consuming. "If it can be, I will try" - Me
Sanjay Joshi

Latest posts by Sanjay Joshi (see all)

Sanjay Joshi

3 comments

Leave a Reply

Your email address will not be published. Required fields are marked *