padmaAPI/lists/views.py
2009-06-14 20:21:10 +05:30

32 lines
782 B
Python

import urllib
from django.utils import simplejson
from django.http import HttpResponse
from django.shortcuts import render_to_response
def getHtmlFromUrl(url):
try:
u = urllib.urlopen(url)
t = u.read()
u.close
except:
return False
return t
def fetchJson(request):
if request.GET['url']:
u = request.GET['url']
json = getHtmlFromUrl(u)
return HttpResponse(json, mimetype="application/javascript")
else:
return HttpResponse("{'error': True}", mimetype="application/javascript")
def index(request):
return render_to_response("index.html")
def listDetail(request):
if request.GET:
rDict = {'listId': request.GET['id'] }
return render_to_response("list.html", rDict)
else:
return HttpResponse("Please pass me a list id:(")