Exemplo n.º 1
0
def redirect(request, nsid, num, popular):
    if not num or not num.isdigit() or int(num) <= 0:
        num = 1
    if not popular:
        popular = ''

    resp = HttpResponse(status=302)
    nsid = getUserNSID(request, resp, apiKey, nsid)
    photo = flickrapi.getPhoto(apiKey, nsid, num, popular)
    destinationUrl = flickrapi.getPhotoPageUrl(photo, nsid)
    resp['Title'] = photo.title.encode("utf-8")
    resp['Location'] = destinationUrl
    return resp
Exemplo n.º 2
0
def image(request, nsid, num=1, size='', popular=''):

    if not num or not num.isdigit() or int(num) <= 0:
        num = 1
    if not size:
        size = 's'
    if not popular :
        popular = ''

    resp = HttpResponse(status=302)
    nsid = getUserNSID(request, resp, apiKey, nsid)
    photo = flickrapi.getPhoto(apiKey, nsid, num, popular)
    destinationUrl = flickrapi.getImageUrl(photo, size)
    resp['Cache-Control'] = "private, max-age=3600"
    resp['Title'] = photo.title.encode("utf-8")
    resp['Location'] = destinationUrl
    return resp