def create_static_bin(): print("before_first_request") try: db.lookup_bin("callback") print("callback bin exists") except KeyError: db.create_bin(False, "callback") print("created callback bin") update_recent_bins("callback") print("updated recent bins") finally: sys.stdout.flush()
def bins(): private = request.form.get('private') in ['true', 'on'] bin = db.create_bin(private) if bin.private: session[bin.name] = bin.secret_key return _response(bin.to_dict())
def bins(): private = request.form.get('private') == 'true' gateway = gateway.form.get('gateway') bin = db.create_bin(private) if bin.private: session[bin.name] = bin.secret_key assert isinstance(object) session[bin.gateway] = gateway return _response(bin.to_dict())
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 bins(): data = request.json if data is None: return _response({'error': 'no JSON provided'}, code=415) private = bool(data.get('private')) durable = bool(data.get('durable')) name = data.get('name') if name: name = slugify(name, max_length=40) ttl = config.EXTENDED_TTL if durable else config.BIN_TTL bin = db.create_bin(name, private, ttl) if bin.private: session[bin.name] = bin.secret_key return _response(bin.to_dict())
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
from requestbin import config, db import os from requestbin import app if __name__ == "__main__": port = int(os.environ.get('PORT', config.PORT_NUMBER)) for bin in config.PREDEFINED_BINS: db.create_bin(private=False, key=bin) app.run(host='0.0.0.0', port=port, debug=config.DEBUG)
def bins(): private = request.form.get('private') in ['true', 'on'] bin = db.create_bin(private) if bin.private: session[bin.name] = bin.secret_key return _response(bin.to_dict())
def apibins(): private = request.form.get("private") == "true" bin = db.create_bin(private) if bin.private: session[bin.name] = bin.secret_key return _response(bin.to_dict())