My adventure into to Twitter land let me to a point. JavaScript alone wasn’t going to cut it. I was going to have to go back to the land of the server. I started investigating different options that were preferably free. I settled upon Google App Engine.
The Google App Engine does lock you down to using Python. I took this as a challenge to delve into Python. The App Engine does not use a traditional relational database, instead it uses BigTable built on Google File System. The App Engine is also scalable, and completely hosted by Google.
This is checklist to get an application running on Google App Engine:
- Sign up for an Application (Requires a Google Account)
- Download the SDK (Requires Python 2.5)
- Create an application using the template provided in SDK
- Upload your application to the AppEngine
Some notes on the App Engine programming, you must use python. You are limited to standard Python 2.5. They provide some extensions, and a limited version of Django. You can upload other “pure Python” extensions.
View my simple Python CGI application for displaying the Twitter trends API call.
My view of the App Engine is it is a service that has potential. The service requires you to download the SDK and work for the command line, so if you are not comfortable with this then it probably is not the service for you. I will probably continue to play with the App Engine, becuase it has some real potential, and I want to learn more about working BigTable.
Once the service is more refined it could be a really smooth way to develop highly scalable web service. Look out for this one as a major player in the cloud market if they decide to take it mainstream with other languages beyond Python.
Here is the source code, also this was my first real dive into Python, beyond just toying with the interpreter (I love it!!!1!)
#!/usr/bin/env python
import wsgiref.handlers
from google.appengine.ext import webapp#url fetchingfrom google.appengine.api import urlfetchfrom datetime import datetime#use the simplejson library, lucky it was in djangofrom django.utils import simplejsonimport time
#Output the html ick, but it's just a exampleoutput = '<html><head></head><body>'output += '<h1>Twitter Trends</h1>'output += '<ul>'
# Make the API call to twitterurl = "http://search.twitter.com/trends.json"result = urlfetch.fetch(url)
#Status code ok?if result.status_code == 200:json = simplejson.loads(result.content)#Loop through the trends listfor i in json['trends']:output += '<li>'output += '<a href="' + i['url'] + '">'output += i['name']output += '</a></li>'
#Finish out the requestoutput += '</ul>'output += '</body></html>'
#The primary handler, just outputs outputclass MainHandler(webapp.RequestHandler):def get(self):self.response.out.write(output)
#Defines the calls through the applicationdef main():application = webapp.WSGIApplication([('/', MainHandler)], debug=True)wsgiref.handlers.CGIHandler().run(application)
if __name__ == '__main__':main()













One Comment
Great overview of Google App Engine and how it can be employed by Twitter apps! Thanks!