Giter Club home page Giter Club logo

bluemix-python-sample-twitter-influence-app's Introduction

How to Run and Deploy the Twitter Influence Analyzer

Overview of the app

This is a Python app that uses the Bottle framework and the following services:

  • Cloudant (backend database)

Download the App

The source for this app is at GitHub so, for example, if you are using the command line you can clone the repository like this:

git clone https://github.com/ibmjstart/bluemix-python-sample-twitter-influence-app.git

External and Public APIs

This app uses some external APIs. You need to register the app with Twitter and Klout to get the keys and tokens for the wsgi.py file.

Twitter v1.1 API

To access the Twitter API you need the consumer keys and access tokens, so you must register the app with Twitter. You can register your app here.

More information on how to register the app with Twitter

Klout API

You can register the app with Klout here. When you register with Klout, you'll get a Klout Key, which you can use to create a Klout Object as shown in the code.

Google Maps v3 API

This app uses the Google Maps v3 APIs. Google APIs are open for the developers and you do not need to register the app with Google. Here's the link for the Google Maps APIs.

Screen-shot of the wsgi.py file that shows where the Twitter keys and access tokens and Klout developer key is entered: image

Deploying the App

After including the Twitter/Klout keys and tokens in the wsgi.py file (as shown above), you are ready to deploy the app. In the terminal, go in the directory of the app (where wsgi.py is located). Multiple methods exist for interacting with the BlueMix platform. Outlined below is one of those methods:

  1. Command-Line

Method: Command-Line

Prerequisites

Before we begin, we first need to install the cf command line tool that will be used to upload and manage your application. If you've previously installed an older version of the cf tool, make sure you are now using v6 of cf by passing it the -v flag:

cf -v

Steps

In the terminal, go to the directory of the app, and follow these steps.

  1. Login to Bluemix.

    usage: $ cf login [-a API_URL] [-o ORG] [-s SPACE]
    example: $ cf login -a https://api.ng.bluemix.net
  2. Create an instance of the MongoDB service, giving it a unique name in the last arguement.

    usage: $ cf create-service SERVICE PLAN SERVICE_INSTANCE
    example: $ cf create-service cloudantNoSQLDB Shared cloudant_PTIA
  3. From the directory that houses the wsgi.py file, push the app with the --no-start option so we can bind our required service before starting. Pass the -c flag to specify the start command that should be used by CloudFoundry to run your app. Pass the -b flag to specify the Python build pack to be used, https://github.com/joshuamckenty/heroku-buildpack-python is recommended. Be sure to give your app a unique app name to be used as its host; for example, the example below would result in https://nmu.mybluemix.net.

    usage: $ cf push APP [--no-manifest] [--no-start] [-c COMMAND]
    example: $ cf push ptia --no-manifest --no-start -b https://github.com/joshuamckenty/heroku-buildpack-python -c "python ./wsgi.py"
  4. Bind the cloudant service instance to the new app

    usage: $ cf bind-service APP SERVICE_INSTANCE
    example: $ cf bind-service ptia cloudant_PTIA
  5. Start the app

    usage: $ cf start APP
    example: $ cf start ptia

requirements.txt

If your Python app requires any external dependencies (i.e. any modules that you install using 'pip install'), you need to include them in the requirements.txt file. Each module must be downloaded and put in the directory of the app (e.g. app), and the relative path to that module must be included in the requirements.txt file.

You should not need to do this to deploy this app because the dependencies are already included in the requirements.txt file, and the external modules are also included in the root directory of the app. While deploying the app, the requirements.txt file should be detected and automatically install the dependencies.

Screenshots

This is the home screen of the app. You can enter a twitter screen name in the text box and click the Analyze button to see their influence. You can also view any records saved in the database by clicking on the 'View Database' button.

image

After entering the twitter name and clicking the Analyze button, you'll be able to see the influence analysis of that person on the left side. You will also see their last 10 tweets and any recent mentions in the tweets plotted on Google Maps (if there is geolocation data for a tweet).

image

These are the records of the Influencers in the database. The user can export the records as csv file. There is also a feature to send the records in csv format to any person via email using the SMTP service, if the SMTP service is not bound to the application you can not do this and the features will be disabled.

image

License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

bluemix-python-sample-twitter-influence-app's People

Watchers

 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.