Sunday, 25 November 2012

App Engine and Google Apps Script

Update on SocialSamplr

Been a while since my last post, but I've been very busy developing our social media scoring platform so it's been hard to find the time to write much - but here's a new post on using memcache and big query on App Engine  Things have been progressing very well and socialsamplr is now on-boarded to the Creative HQ business incubator here in Wellington NZ and we're looking forward to accelerating things a lot from here on in.
We've been following the "lean startup" process and think we've got the information now to build a pretty cool and unique minimum viable product so stay tuned on how it progresses.  If anyone is interested in discussing what the product is going to offer or to even be beta testers please contact me at  Also, being a cash-strapped startup, if anyone's interested in the source code for the Google apps script stuff I was working on last year I'd be happy to provide this for a small fee along with some training data to create your own sentiment engine (kind of a "build your own sentiment engine starter pack").  Again, just drop me line and we can work something out (here's the link to see that in action

Getting Started in Python and App Engine

The new python site which I'll be hosting on app engine is still in progress but I've already got a couple of quick things to show so I thought I'd do a short initial post.

As a start I've installed Eclipse to use as the development environment with the Python and app engine extensions.  For the web development framework I've decided to go with Django (supported on app-engine), mysql database and am using the Twitter bootstrap css for styling.  So far it's proven very easy to get started using Python (being from a .NET background I've been very impressed so far with the intuitive nature of the language, although open-source development environments take a bit of getting used to after Visual Studio).  The django framework provides an MVC sort of pattern which is a great way to build web apps and also has plenty of built-in functionality like session management - which is limited to say the least in Google sites.  The dev environment is shown below:

An initial sample of the new site in progress is shown here, with the nice new "web 2.0" look that you get with the Twitter bootstrap (still getting my head around css a bit, but getting there!).

Integrating with Google Apps Script

So the first thing I wanted to try was see how it integrates with Google Apps Script so I can use script gadgets easily within the site.  The answer is very easy.  

The first thing you'll need to do is run a web application in Google App Engine to act as a proxy site for your Google Apps Script.  A sample application has been very kindly provided by "Eddy" as per Issue 546 (related to hosting google script gadgets on a custom domain).  See comment 104 on this issue to cover how to set up your proxy site application.  Once this is done you'll be able to host Apps Script gadgets within an iFrame on your app engine site - just replace the part of the url with and you should be good to go.

Once you have set up your site to host apps script gadgets you can also then set up server-side communication between your app-engine site and google apps scripts.  On the python side this is very simple to call your apps script page - just see as follows using the built-in urlfetch method.

url = ""

result = urlfetch.fetch(url)

Then in Apps Script by using the ContentService you can simply return the response as a string from the doGet function as follows - this will then be restored in the result variable seen above.  You see here we first check for the appkey from the query string to verify the requesting identity and then return a new value.  

This provides a very simple and secure way (all communication being via SSL) to communicate between an app engine site and Google Apps Scripts.  This is particularly good for being able to quickly develop and deliver functionality without having to redeploy your whole site.  In addition, it allows the use of all of the APIs available with Google Apps Script without having to code up all your authentication (for example Oauthing in first).  So long as all the requests are kept server-side it should be nice and secure.  Obviously, it will be slower than running executing everything within your python app, but does give some great options around flexibility.

So that's about it for now, will have some more stuff soon.  

Real-time Sentiment Scoring

As a footnote, I've created a new real-time sentiment scoring engine for any subject using data from Facebook, Google+ and Twitter and enriched with Klout.  Check it out on the existing website at

No comments:

Post a Comment