Mobile RSSmeme

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!

Tags: , ,

2 Responses to “Mobile RSSmeme”

  1. J. Phil says:

    Testing the code tag.. sorry for using your blog as a testing ground, Benjamin.


    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))

  2. J. Phil says:

    Sweet, it kind of works! Takes out the spaces, though. You probably knew that already, though.

    … you can actually delete these comments if you like, Benjamin. Thanks.

Leave a Reply