Crossdomain proxy on Google App Engine

Here’s a crossdomain proxy to pipe Javascript Ajax calls from you Google App Engine application to the Flickr API, since most browser will not let you call another domain directly.

import cgi
import urllib
from google.appengine.ext import webapp
from google.appengine.api import urlfetch

class FlickrController(webapp.RequestHandler):
	"""Proxy for Ajax calls to flickr"""
	def get(self):
		flickrapiendpoint = 'http://api.flickr.com/services/rest/'
		flickrapikey = 'you_flicker_api_key'
		
		params = self.request.GET
		params.add('api_key', flickrapikey)
		params.add('format', 'json')
		apiquery = urllib.urlencode(params)
		
		result = urlfetch.fetch(url=flickrapiendpoint + '?' + apiquery, method=urlfetch.GET)
		self.response.out.write(result.content)

def main():
	application = webapp.WSGIApplication(
		[('/flickr/', FlickrController)],
		debug=True)
	wsgiref.handlers.CGIHandler().run(application)

if __name__ == "__main__":
	main()

I didn’t see examples of such a script anywhere else so I thought I’d post it here for all to see.

WWDC Keynote

Tonight (at least in Japanese time) is Steve Job’s WWDC Keynote. It is widely accepted that he will be announcing the new 3G enabled iPhone and I am secretly hoping he will give us a release date for Japan live from the Moscone West.

These past weeks, I’ve been developing a live-blogging system for my other website to cover the event minute by minute. It’s a challenge to devise a system, both software and hardware-wise, capable of handling the huge loads involved in such a big event. We are expecting more than 50.000 persons to follow the Keynote via MacBidouille.

Until now, all our attempts have failed. But this time, I’m trying something new with an Ajax based interface running on the new Google App Engine platform. It’s been really fun using a new technology, Python, on Google’s own architecture.

I have no idea if this new system will withstand the load this year, especially with the tight quotas in place for the beta phase of App Engine. But I sure hope Steve announces the iPhone launch in Japan starting tomorrow and I’ll take the day-off to rush to the Apple Store in Ginza as soon as it opens…

Address Power

Last July I wrote about a popular Japanese webservice that built an image of your brain out of your name. Everyone at work and on TV was talking about it. The concept was even copied overseas (replacing the kanjis with emoticons).

This weekend I saw on TV another of those websites that you know everyone will talk about. Its name is 住所パワー which aims at calculating your “Address Power” from the number and proximity of restaurants, schools, train stations, etc.

住所パワー - Address Power

My address, even though I live out in the relative boondocks, 20 minutes from 池袋 – the closest station on the Yamanote line – into 埼玉県, scored a nice 3,321 points and is ranked A-class.

details of my ranking

Here are the results by criterion, with the number of shop and the distance to the closest one (I added the translations). I probably owe my good score to being extremely close to the station and across the street from a supermarket on one side and a mall on the other.

Note that the number of Love Hotels and 風俗 – basically any kind of shop/bar/club/salon related to the sex industry – comes as a criterion, although they probably need a broader databases because there are at least 2 dozen hostess bars/キャバクラ in a 200m circle around my place that should have gotten me a lot more points…