def post(self):
        self.error_message = None
        self.stati = None

        # Process input
        if self.request.body:
            request_body = json.loads(self.request.body)
            if "text" in request_body:
                user_input = request_body["text"]
                if len(user_input) > 0:

                    # Make call to twitter search api with user input
                    try:
                        stats = TwitterSearch.search(user_input)
                        try:
                            if len(stats)>0:
                                self.stati = stats
                            else:
                                self.error_message = \
                                    "No one seems to care about that topic.."
                        except Exception as e:
                            self.error_message = \
                                "Twitter is having some technical problems.."
                    except Exception as e:
                        self.error_message = str(e)
                else :
                     self.error_message = "Enter something.."
        # Return results
        data = {
            "error_message": self.error_message,
            "stati": self.stati
        }
        self.response.out.write(json.dumps(data))
 def test_search_twitter(self):
     print TwitterSearch.search("something")
     print TwitterSearch.search("@")
     print TwitterSearch.search("@james")
     print TwitterSearch.search("#help")
     print TwitterSearch.search("")
 def test_get_twitter_api(self):
     api = TwitterSearch.get_api()
     self.assertTrue(api is not None)