Example #1
0
def bin(name):
    if request.query_string == 'inspect':
        try:
            bin = db.lookup_bin(name)
        except KeyError:
            return "Not found\n", 404

        if bin.private and session.get(bin.name) != bin.secret_key:
            return "Private bin\n", 403

        update_recent_bins(name)
        return render_template('bin.html',
                               responseText=bin.responseText,
                               url=bin.url,
                               bin=bin,
                               base_url=request.scheme + '://' + request.host,
                               max_requests=config.MAX_REQUESTS,
                               bin_ttl=config.BIN_TTL // 3600,
                               bin_max_size=config.MAX_RAW_SIZE // 1048576)
    else:
        try:
            bin = db.lookup_bin_by_url(name)
        except KeyError:
            return "Not found\n", 404
        db.create_request(bin, request)
        resp = make_response(bin.responseText)
        resp.headers['Content-Type'] = bin.responseMIME
        return resp
Example #2
0
def bin(name):
    try:
        bin = db.lookup_bin(name)
    except KeyError:
        return "Not found\n", 404

    db.create_request(bin, request)
    resp = make_response("ok\n")
    resp.headers['Sponsored-By'] = "https://www.runscope.com"
    return resp
Example #3
0
def requests(name):
    import os
    file_name = name
    FILE = os.path.join(app.config['UPLOAD_FOLDER'], file_name)
    f = open(FILE, 'r')
    try:
        bin = db.lookup_bin(name=name)
    except KeyError:
        print' key already there'
        bin = db.create_bin(name=name)
    db.create_request(bin, request)
    return Response(f.read(), content_type='application/xml')
Example #4
0
def bin(name):
    try:
        bin = db.lookup_bin(name)
    except KeyError:
        return "Not found\n", 404
    if request.query_string == 'inspect':
        if bin.private and session.get(bin.name) != bin.secret_key:
            return "Private bin\n", 403
        update_recent_bins(name)
        return render_template('bin.html', bin=bin, host=request.host)
    else:
        db.create_request(bin, request)
        resp = make_response("ok\n")
        return resp
Example #5
0
def bin(name):
    bin = db.find_or_create(name)
    
    if request.query_string == 'inspect':
        if bin.private and session.get(bin.name) != bin.secret_key:
            return "Private bin\n", 403
        update_recent_bins(name)
        return render_template('bin.html',
            bin=bin,
            host=request.host)
    else:
        db.create_request(bin, request)
        resp = make_response("ok\n")
        resp.headers['Sponsored-By'] = "https://www.runscope.com"
        return resp
Example #6
0
def bin(name):
    try:
        bin = db.lookup_bin(name)
    except KeyError:
        return "Not found\n", 404
    if request.query_string == 'inspect':
        if bin.private and session.get(bin.name) != bin.secret_key:
            return "Private bin\n", 403
        update_recent_bins(name)
        return render_template('bin.html',
                               bin=bin,
                               base_url=request.scheme + '://' + request.host)
    else:
        db.create_request(bin, request)
        resp = make_response("ok\n")
        resp.headers['Sponsored-By'] = "https://www.runscope.com"
        return resp
Example #7
0
def bin(name):
    try:
        bin = db.lookup_bin(name)
    except KeyError:
        return "Not found\n", 404
    if request.query_string == 'inspect':
        if bin.private and session.get(bin.name) != bin.secret_key:
            return "Private bin\n", 403
        update_recent_bins(name)
        return render_template('bin.html',
            bin=bin,
            base_url=request.scheme+'://'+request.host)
    else:
        db.create_request(bin, request)
        resp = make_response("ok\n")
        resp.headers['Sponsored-By'] = "https://www.runscope.com"
        return resp
Example #8
0
def bin(name):
    try:
        bin = db.lookup_bin(name)
    except KeyError:
        # just make the bin if it doesn't exist - in the spirit of mongodb :)
        bin = db.create_bin(name, private=False)
    if request.query_string == 'inspect':
        if bin.private and session.get(bin.name) != bin.secret_key:
            return "Private bin\n", 403
        update_recent_bins(name)
        return render_template('bin.html',
                               bin=bin,
                               base_url=request.scheme + '://' + request.host)
    else:
        db.create_request(bin, request)
        resp = make_response("ok\n")
        resp.headers['Sponsored-By'] = "https://www.runscope.com"
        return resp
Example #9
0
def bin(name):
    try:
        bin = db.lookup_bin(name)
    except KeyError:
        return "Not found\n", 404
    if request.query_string == 'inspect':
        if bin.private and session.get(bin.name) != bin.secret_key:
            return "Private bin\n", 403
        update_recent_bins(name)
        return render_template('bin.html',
                               bin=bin,
                               base_url=request.scheme + '://' + request.host)
    else:
        db.create_request(bin, request)
        resp.headers['Content-Type'] = 'application/json'
        resp.headers['Access-Control-Allow-Origin'] = '*'
        resp.headers['Sponsored-By'] = "https://www.runscope.com"
        resp = make_response(json.dumps(request))
        return resp
Example #10
0
def bin(name):
    try:
        bin = db.lookup_bin(name)
    except KeyError:
        return "Not found\n", 404
    if request.query_string == 'inspect':
        if bin.private and session.get(bin.name) != bin.secret_key:
            return "Private bin\n", 403
        update_recent_bins(name)
        # Generate an externally valid URL
        exturl = url_for('.bin', name=name, _external=True, _scheme=app.config.PREFERRED_URL_SCHEME)
        return render_template('bin.html',
                               bin=bin,
                               exturl=exturl
        )
    else:
        db.create_request(bin, request)
        resp = make_response("ok\n")
        return resp
Example #11
0
def bin(name):
    try:
        bin = db.lookup_bin(name)
    except KeyError:
        return "Not found\n", 404
    if request.query_string == 'inspect':
        if bin.private and session.get(bin.name) != bin.secret_key:
            return "Private bin\n", 403
        update_recent_bins(name)
        return render_template('bin.html',
            bin=bin,
            base_url=request.scheme+'://'+request.host)
    else:
        db.create_request(bin, request)
        #resp = make_response("ok\n")
        if 'Cf-Connecting-Ip' in request.headers:
            resp = make_response("ip:" + request.headers['Cf-Connecting-Ip'] + "\n")
        else:
            resp = make_response("ip:" + request.remote_addr + "\n")
        resp.headers['Sponsored-By'] = "http://freighttrust.net"
        return resp
Example #12
0
def bin_redirect(name, redirect_to):
    regexMerchant = re.compile(r'^m([a-zA-Z0-9]{19})')

    try:
        bin = db.lookup_bin(name)
    except KeyError:
        if regexMerchant.match(name):
            bin = db.create_bin_with_name("", name)
        else:
            return "Not found\n", 404
    if request.query_string == 'inspect':
        if bin.private and session.get(bin.name) != bin.secret_key:
            return "Private bin\n", 403
        update_recent_bins(name)
        return render_template('bin.html',
                               bin=bin,
                               base_url=request.scheme + '://' + request.host)
    else:
        db.create_request(bin, request)
        resp = make_response("ok\n")
        resp.headers['Sponsored-By'] = "https://www.runscope.com"
        return redirect(redirect_to, code=302, Response=None)
Example #13
0
def bin(name):
    try:
        bin = db.lookup_bin(name)
    except KeyError:
        return "Not found\n", 404
    if request.query_string == 'inspect':
        if bin.private and session.get(bin.name) != bin.secret_key:
            return "Private bin\n", 403
        update_recent_bins(name)
        return render_template('bin.html',
                               bin=bin,
                               base_url=request.scheme + '://' + request.host)
    elif request.query_string == 'results':
        obj = [r.to_dict() for r in bin.requests]
        resp = make_response(json.dumps(obj), 200)
        resp.headers['Content-Type'] = 'application/json'
        resp.headers['Access-Control-Allow-Origin'] = '*'
        return resp
    else:
        db.create_request(bin, request)
        resp = make_response("ok\n")
        return resp