This morning I built a mobile RSSmeme using the RSSmeme API. It is only 50 lines of templates and code in order to generate this page. It is simply a mobile representation of the RSSmeme front page. See how easy it is to work with the API?
Here’s the code:
import urllib2
from django.core.cache import cache
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.utils import simplejson
CACHE_TIME = 60 * 5
def home(request):
URL = 'http://www.rssmeme.com/?output=json&language=en'
key = URL
json = cache.get(key)
if not json:
json = simplejson.load(urllib2.urlopen(URL))
cache.set(key, json, CACHE_TIME)
return render_to_response('base.html', {'entries': json['entries']}, context_instance = RequestContext(request))
And base.html is just a simple template. There’s nothing to it!
