Beispiel #1
0
def future_price_detail(request, future_price_id):

    #Check for rate limiting if too many requests
    max_allowable_requests = 7200
    ip = util.get_client_ip(request)
    Rate_Limit.objects.create(ip=ip, function='future_price_detail')
    limit = Rate_Limit.objects.filter(ip=ip, function='future_price_detail').count()
    if limit > max_allowable_requests:
        error_text = _("Slow down <span class='notranslate'>Rainman</span> - you've made too many requests in the last hour")
        return HttpResponse(error_text, mimetype="text/plain", status=429)

    f = get_object_or_404(Future_Price, id=future_price_id)
    future_price = get_future_price_data(f)
    return render_to_response("prediction_detail.html", future_price, context_instance=RequestContext(request))
Beispiel #2
0
def future_price_detail_api(request, future_price_id, data_type):
    
    #Check for rate limiting if too many requests
    max_allowable_requests = 7200
    ip = util.get_client_ip(request)
    Rate_Limit.objects.create(ip=ip, function='future_price_detail')
    limit = Rate_Limit.objects.filter(ip=ip, function='future_price_detail').count()
    if limit > max_allowable_requests:
        error_text = _("Slow down <span class='notranslate'>Rainman</span> - you've made too many requests in the last hour")
        return HttpResponse(error_text, mimetype="text/plain", status=429)

    if data_type != "json":
        error_text = _("Invalid data type")
        return HttpResponse(error_text, mimetype="text/plain", status=400)
        
    f = get_object_or_404(Future_Price, id=future_price_id)
    future_price = get_future_price_data(f)
    return HttpResponse(json.dumps(future_price), mimetype="application/json")
Beispiel #3
0
def future_price_detail(request, future_price_id):

    #Check for rate limiting if too many requests
    max_allowable_requests = 7200
    ip = util.get_client_ip(request)
    Rate_Limit.objects.create(ip=ip, function='future_price_detail')
    limit = Rate_Limit.objects.filter(ip=ip,
                                      function='future_price_detail').count()
    if limit > max_allowable_requests:
        error_text = _(
            "Slow down <span class='notranslate'>Rainman</span> - you've made too many requests in the last hour"
        )
        return HttpResponse(error_text, mimetype="text/plain", status=429)

    f = get_object_or_404(Future_Price, id=future_price_id)
    future_price = get_future_price_data(f)
    return render_to_response("prediction_detail.html",
                              future_price,
                              context_instance=RequestContext(request))
Beispiel #4
0
def future_price_detail_api(request, future_price_id, data_type):

    #Check for rate limiting if too many requests
    max_allowable_requests = 7200
    ip = util.get_client_ip(request)
    Rate_Limit.objects.create(ip=ip, function='future_price_detail')
    limit = Rate_Limit.objects.filter(ip=ip,
                                      function='future_price_detail').count()
    if limit > max_allowable_requests:
        error_text = _(
            "Slow down <span class='notranslate'>Rainman</span> - you've made too many requests in the last hour"
        )
        return HttpResponse(error_text, mimetype="text/plain", status=429)

    if data_type != "json":
        error_text = _("Invalid data type")
        return HttpResponse(error_text, mimetype="text/plain", status=400)

    f = get_object_or_404(Future_Price, id=future_price_id)
    future_price = get_future_price_data(f)
    return HttpResponse(json.dumps(future_price), mimetype="application/json")