def increase(request): name = request.POST.get('counter_name') name = re.sub(ur"\s+", " ", name.strip()) # Flood control. ip = request.META.get('HTTP_X_FORWARDED_FOR') or request.META.get('REMOTE_ADDR') key = ('inc', ip, name) if store.get(key): return HttpResponseForbidden(u'Flood') store.set(key, 1) store.expire(key, 3) if name: #tasks.inc_counter_by_name.delay(name) api.inc_counter_by_name(name) if request.is_ajax(): return HttpResponse('') #update(request) else: return redirect('/')
def inc_counter_by_name(name): api.inc_counter_by_name(name)