Exemple #1
0
def shurl_stats(request,short_suffix):
    '''Returns how many times a given short URL has been accessed -- human readable'''
    n = convert_from_base_64(short_suffix)
    shurl = get_object_or_404(Shurl,pk=n)
    return HttpResponse('URL ' + short_suffix + ' has been accessed ' + str(shurl.access_count) + ' time(s).')
Exemple #2
0
def shurl_accesses(request,short_suffix):
    '''Returns how many times a given short URL has been accessed'''
    n = convert_from_base_64(short_suffix)
    shurl = get_object_or_404(Shurl,pk=n)
    return HttpResponse(str(shurl.access_count))
Exemple #3
0
def forward(request,short_suffix):
    '''Given the suffix of a short url, forwards us on to that short url's real url'''
    n = convert_from_base_64(short_suffix)
    shurl = get_object_or_404(Shurl,pk=n)
    # get_url() updates the appropriate access_counts and returns the url
    return redirect(shurl.get_url())