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
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
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')
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
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
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
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
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
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
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
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
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)
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